cancel
Showing results for 
Search instead for 
Did you mean: 

Select and highlight a default row in a table

Former Member
0 Kudos

Hi everybody.

When using a table in WD, the first line is selected and highlighted by default.

I'd like to reproduce the same behaviour but this time, the selected and highlighted row shouldn't be the first row but any other one that has to be defined previously.

How could I do that??

Thanks for any suggestions you may have.

Regards,

C.

Accepted Solutions (0)

Answers (3)

Answers (3)

uday_gubbala2
Active Contributor
0 Kudos

For example I have a node SFLIGHT which am using to display data in tabular format on my layout. I have attached a supply function POPULATE_DATA to my context node SFLIGHT to fetch & populate the node.

METHOD populate_data .
  DATA: lt_sflight TYPE wd_this->elements_sflight.

  SELECT carrid
         connid
         fldate
         price FROM sflight INTO TABLE lt_sflight.
  node->bind_table( new_items = lt_sflight ).
ENDMETHOD.

And within my WDDOINIT method am programmatically setting the LeadSelection to the 3rd row as how shown below:

METHOD wddoinit .
  DATA: wd_node TYPE REF TO if_wd_context_node.

  wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
  wd_node->set_lead_selection_index( '3' ).
ENDMETHOD.

Regards,

Uday

uday_gubbala2
Active Contributor
0 Kudos

Hi Cristina,

You see the first row of the table as selected & highlighted in a different colour because of the LeadSelection. If you go to the context node which you are using to bind to your table you can see a check box which says as

Initialization Lead Selection

If this checkbox is checked then the system does by default set the first element with your context node as selected which is what's happening in your case.

You can also however set the LeadSelection on to a different table row programmatically. You need to use the method SET_LEAD_SELECTION_INDEX OF IF_WD_CONTEXT_NODE for the same. Just obtain a reference of your context node & then call the SET_LEAD_SELECTION_INDEX using the fetched reference & pass the row number which you want to be as selected.

Regards,

Uday

Former Member
0 Kudos

Hi,

When you bind the context node with table of data, by default the first rows gets selected as lead selection, if you enable lead selection on the TABLE ELEMENT in the VIEW.

If you want to change the lead selection to some other index instead of first row, method SET_LEAD_SELECTION_INDEX of IF_WD_CONTEXT_NODE can be used by just passing the INDEX of the row you want to select.

If your table is with property 'SELECTION MODE' as 'MULTI' and if you want multiple rows to be selected, then you can use method SET_SELECTED of IF_WD_CONTET_NODE multiple times by passing different INDEX values.

Regards,

Manne.