cancel
Showing results for 
Search instead for 
Did you mean: 

Get index of table row when dropdown is selected

Former Member
0 Kudos

Hi Experts,

I have a table with a dropdown field. How can i get the index of the row when the dropdown field is selected ?

Thanks,

Prisford Pereira

Accepted Solutions (0)

Answers (3)

Answers (3)

amy_king
Active Contributor
0 Kudos

Hi Prisford,

Rama and Sankar are both correct, I just wanted to add that you may also include the standard event handler parameter, CONTEXT_ELEMENT in the signature of your event handler method as follows...

and then you may directly write..


context_element->get_index( ).

Note that the CONTEXT_ELEMENT parameter will only ever be populated if the event occurs within a Table (so a 0..n or 1..n context node). If you had a stand-alone dropdown for example (outside of a Table), the CONTEXT_ELEMENT parameter would be null in the event handler method.

Cheers,

Amy

former_member222068
Active Participant
0 Kudos

Hi pereira,

To read the selected record or index. In the event handler methods, we have a  parameter called

WDEVENT.

Data : lo_el_data type ref to if_wd_context_element.

lo_el_data = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

lv_index = lo_el_data->get_index( ).

Thanks & Regards,

Sankar Gelivi


ramakrishnappa
Active Contributor
0 Kudos

Hi Prisford,

You can achieve your requirement as below

  • Create an action DD_SELECT( ) for OnSelect event of drop down column
  • Now, on drop down field selection, the event handler ONACTIONdd_select( ) will trigger
    • inside the method you have the parameter WDEVENT

          write the below code to get the current index of row

              

               data lo_element type ref to if_wd_context_element.

               data lv_curr_row_index type i.

       

                    lo_element = wdevent->get_context_element( name = 'CONTEXT_ELEMENT' ).

                    lv_curr_row_index = lo_element->get_index(  ).

Hope this helps you.

Regards,

Rama