cancel
Showing results for 
Search instead for 
Did you mean: 

How to select a table row by clicking on a cell?

Former Member
0 Kudos

Hi everyone,

How can I select a table row just clicking on a cell?

I would like to get the row index in which I click.

Thanks a lot!!

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Thanks for you replies!

Eventually I did not need to do that! After one day struggling with it!!...Grrrrrrr

Sharathmg
Active Contributor
0 Kudos

**** it happens.

Former Member
0 Kudos

Hi David,

You need to trigger an event when you click on cell.

In that event try to get the table index of that particular column by reading internal table using that field. After getting index write the following code. It will set the lead selection to the desired row by passing index no.

  DATA lv_set_ind TYPE i.

  lo_nd_parts_consumed1 = wd_context->get_child_node( name = wd_this->wdctx_parts_consumed ).

  lo_el_parts_consumed1 = lo_nd_parts_consumed1->get_element(  ).

  CALL METHOD lo_nd_parts_consumed1->set_lead_selection_index

    EXPORTING

      index = lv_set_ind.

Hope it helps.

Happy Coding,

Keshav

Sharathmg
Active Contributor
0 Kudos

If in the row / column in which you click in associated with action then perform, parameter mapping for the action linked to the element.

You can map a link/button with the node element. The mapping is performed (only firsttime i.e. once in the WDMODIFYVIEW ). So when the user clicks on the link/button(or any ui element which supports parameter mapping) then you will have the selected element in the table as parameter of the action linked to the ui element.

Refer this document for more help: http://help.sap.com/saphelp_nw04s/helpdata/en/33/b11042705a5533e10000000a155106/frameset.htm

http://help.sap.com/saphelp_nw04s/helpdata/en/f9/64c0410c2dcc17e10000000a155106/frameset.htm

Regards,

Sharath

former_member184578
Active Contributor
0 Kudos

Hi,

Change your table cell ( Column) to Link to Action, then in onAction of link_to_action cell editor, write the below code

DATA lr_el_element TYPE REF TO if_wd_context_element.

   DATA lv_index TYPE i.


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

    lv_index = lr_el_element->get_index( ).

Here lv_index contains the clicked index.  Now use set_lead_selection_index( ) method to set the selection for row.

lo_nd_node->set_lead_selection_index( lv_index ).  " here lo_nd_node is the reference of your node

Hope this helps u.,

Regards,

Kiran


Former Member
0 Kudos

, How many times you had replied with the same code in past .. After watching this kind of question, in activity, by heading only, One picture is coming in mind, That picture looks like same as your comment ..

former_member184578
Active Contributor
0 Kudos

Yep. I guess I have replied questions like this earlier. I find it more easy to write the code for OP's requirement rather that searching for my previous threads and linking some part of required code to the old thread and writing remaining code  

Former Member
0 Kudos

yes. Its only 4 line of code ..