cancel
Showing results for 
Search instead for 
Did you mean: 

Selected row in a table initially

Former Member
0 Kudos

Hello,

I´ve created a normal table (not ALV) to display information. When the view is displayed, the table has the first row selected, when it shouldn´t be selected. I do not know to to avoid this.

I unchecked the check mark "Initialization lead structure" in the component controller for that structure and when I run the application, I get the following short dump:

Adapter error in &VIEW_ELEMENT_TYPE& "SYST_DESCR" of view "ZIAM.SYSTEM_VIEW": Context binding of property VALUE cannot be resolved: Lead selection not set for context node SYSTEM_VIEW.1.SYSTEMS

Can somebody help me ??

Thanks.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Check for the table UI element for the same property.Selection mode as NONE. Is this set.

Regards,

Lekha.

Former Member
0 Kudos

Hi,

there´s no property "Lead selection" in the table.

Selection mode is set to Single

uday_gubbala2
Active Contributor
0 Kudos

Hi Jorge,

I guess that the changes that you have made at your component controller level haven't got updated in your view. Just go to your views context, right click on it and say update mapping.

Your table row would get automatically selected on running your application only when "Initialization Lead Selection" is checked. (I assume that you haven't written any coding which you do anything like setting the lead selection. Coz this would be the only other possibility left out...) The selection mode of your table has nothing to do with the row being displayed as selected on startup.

Regards,

Uday

Former Member
0 Kudos

Hi,

I´ve updated the component controller in the view and nothing. I still get the short dump.

I deleted later the node and declared the node again. I still get the short dump.

And yes, there´s no code for the lead selection.

There are 3 nodes hanging from my component controller. One of them is the binding to the table and no one hangs from another as a subnode. 2 of them are declared as nodes in the view´s controller.

Former Member
0 Kudos

Hi,

To avoid dump, keep the 'Initialization lead selection' active(check this again), and to avoid lead selection you can do following.

Go to your table UI element properties tab in VIEW and go to the property 'selection mode' and the values you will see as below.

auto - None

single - single selection with lead selection active

multi - Multiple selection with lead selection active

none - No selection allowed in Ui

singleNolead - Single selection allowed in UI with no lead selection

MultiNolead - Multiple selection allowed in UI with no lead selection

The last two will disable the lead selection(but allow manual sel in UI) and based on your requirement you can go for the needed one.

Regards,

manne.

Former Member
0 Kudos

Ok, thanks. It works.

Unfortunately, now the problem is that I cannot get the selected row as before. The code gets always the first record and not the selected one:

DATA: lo_nd_systems   TYPE REF TO if_wd_context_node,
        lo_el_systems   TYPE REF TO if_wd_context_element,
        ls_systems      TYPE wd_this->element_systems.

* navigate from <CONTEXT> to <SYSTEMS> via lead selection
  lo_nd_systems   = wd_context->get_child_node( name = wd_this->wdctx_systems ).

* get element via lead selection
  lo_el_systems  = lo_nd_systems->get_element(  ).

* get all declared attributes
  lo_el_systems->get_static_attributes( IMPORTING static_attributes = ls_systems ).

So the questions are: why do WebDynpro do this ?? and how do I get the selected node ??

Former Member
0 Kudos

Hi,

Get all the selected elements in the context node using the below code(using same example that you used above).

data: lo_all_sel_elements type WDR_CONTEXT_ELEMENT_SET,
                   lo_single element type IF_WD_CONTEXT_ELEMENT.
 "get all the selected elements from UI
  lo_all_sel_elements = lo_nd_systems->GET_SELECTED_ELEMENTS( )

  "loop through all these elements and use the same method GET_STATIC_ATTRIBUTES 
  "to read the selected element data.
  loop at lo_all_sel_elements into lo_single_element.
     lo_single_element-get_static_attributes( importing static_attributes = ls_systems ).
  endloop.

Regards,

Manne.

Edited by: Raja Sekhar Manne on Jun 8, 2009 12:33 PM

Edited by: Raja Sekhar Manne on Jun 8, 2009 12:35 PM

uday_gubbala2
Active Contributor
0 Kudos

Hi Jorge,

Do you want the user to be able to select a single/multiple rows? If you want the user to be able to select multiple rows then you can set the tables "selectionMode" property to multiNoLead. You can then fetch all the rows selected by the user using the get_selected_elements method. Try check the code snippet below where i am fetching the rows selected by the user in 1 table & copying them to another table.

METHOD onactioncopy_selected_rows .
  DATA:  wd_node TYPE REF TO if_wd_context_node,
         ls_node1 TYPE ig_componentcontroller=>element_node1,
         lt_node1 TYPE ig_componentcontroller=>elements_node1,
         lt_node2 TYPE ig_componentcontroller=>elements_node2,
         wa_temp  TYPE REF TO if_wd_context_element,
         lt_temp  TYPE wdr_context_element_set.


  wd_node = wd_context->get_child_node( name = 'NODE1' ).

  CALL METHOD wd_node->get_selected_elements
    RECEIVING
      set = lt_temp.

  wd_node = wd_context->get_child_node( name = 'NODE2' ).

  LOOP AT lt_temp INTO wa_temp.
    CALL METHOD wa_temp->get_static_attributes
      IMPORTING
        static_attributes = ls_node1.
    APPEND ls_node1 TO lt_node1.
    CLEAR ls_node1.
  ENDLOOP.

  wd_node->bind_table( new_items = lt_node1 ).
ENDMETHOD.

uday_gubbala2
Active Contributor
0 Kudos

If you however want the user to be able to select only 1 row then you can try set the "selectionMode" property to "singleNoLead". This is important that you either set it to singleNoLead/multiNoLead coz otherwise when you try to fetch the rows selected the system would be detecting 1 row less than the selected rows. This is because the system would consider the first row to be selected due to LeadSelection. The get_selected_elements doesn't capture any rows that you select by LeadSelection.

Regards,

Uday

Former Member
0 Kudos

Ok, guys. Thanks a lot for your help.

Answers (1)

Answers (1)

uday_gubbala2
Active Contributor
0 Kudos

Regarding the error that you get up on removing the, "Initialization Lead Selection" checkbox. Do you have any subnode created for your node & are trying to display its data in another table? Coz this seems to be a case of the subnode loosing track of its parents leadselection.

Regards,

Uday