cancel
Showing results for 
Search instead for 
Did you mean: 

how to get row index ?

Former Member
0 Kudos

Hi

i have table in my webdynpro that its cells are from type 'LINK_TO _ACTION'.

Is there a way to get the index of the the cell's row which the user pressed on and executed the action attached?

Thanks

Ami 

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

You can get the index on clicking of the link_to_action cell. Write the below code in onAction of link_to_action cell editor:

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( ).

Now lv_index contains the index of clicked column.

Hope this helps u.,

Regards,

Kiran


former_member184611
Active Participant
0 Kudos

Hi Ami,

There is actually a number of ways to do this, one is by creating an 'onSelect' event method for your table. A second method is a more generic way which allows you to add the functionality to any action/process within your webdynpro application. You could therefor have a separate button which captures which row has been selected.  (These two methods assume lead selection is being used, if lead selection is not active on your table element then you will need to use the GET_SELECTED_ELEMENTS method to retrieve the selected rows.)

 

From the actions tab you can double click on your button ACTION to view its associated method and add the below ABAP code to it. In the sample code below 'CARRIERS' is the context node assigned to the table.

  Data: context_node type ref to if_wd_context_node.

  Data: it_scarr type STANDARD TABLE OF if_view1=>element_CARRIERS,

        wa_scarr like line of it_scarr.

  data: ld_element   type ref to if_wd_context_element.

  context_node = wd_context->get_child_node( name = 'CARRIERS').

  ld_element   = context_node->get_lead_selection( ).

  if  not ld_element is INITIAL.

    ld_element->get_static_attributes( IMPORTING

                                        static_attributes = wa_scarr ).

  endif.

* Data of selected row is now contained in wa_scarr

Thanks and Regards,

Abyson Joseph

Answers (2)

Answers (2)

uppu_narayan
Active Participant
0 Kudos

Hi Ami,

     Follow the below link it has clear explanation

http://webdynproabap.wordpress.com/2012/10/05/table-link/

Regards,

Narayan

Former Member
0 Kudos

Hello,

try this..

       DATA lr_element TYPE REF TO if_wd_context_element.
  
DATA lv_index type i.
   lr_element
= wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
   lv_index
= lr_element->get_index( ).

BR

Chandra..