cancel
Showing results for 
Search instead for 
Did you mean: 

Get row selected at cursor action.

Former Member
0 Kudos

Hi,

I am new in web dynpro programming and I need help with getting a row selected when a tab from the column gets selected with the cursor.

For example if I click on the sales org. id tab then entire row should get selected as in the second image.

        

I found some information about the lead selection, but that only brings the manually selected line.

How can I select the row automatically?

Any help is much appreciated.

Best regards,

Elena

Accepted Solutions (1)

Accepted Solutions (1)

former_member184578
Active Contributor
0 Kudos

Hi,

There are no onFocus events in Web Dynpro ABAP like in java script. Only way you could do is, create an Event onEnter for the Input fied ( Sales Org) and set the lead selection in the onEnter event. User must press Enter.

Regards,

Kiran

Former Member
0 Kudos

Hi Kiran,

Thank you for your reply. The thing is the Input Field(Sales Org) already has an onEnter event. The one that brings up the sales organizations. Perhaps I could include in the same method also the lead selection.

Do you have any ideea how the syntax would look like in this case?

Thank you.

Elena

bustamantejt
Explorer
0 Kudos

You can try using the method set_lead_selection_index( lv_index ) where lv_index should be the number of the row that you want to get marked.


DATA: lo_nd_node TYPE REF TO if_wd_context_node,

      lo_el_node TYPE REF TO if_wd_context_element,

      lv_index  TYPE i.

lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).

CALL METHOD lo_nd_node->set_lead_selection_index( lv_index ).

ramakrishnappa
Active Contributor
0 Kudos

Hi Elena,

You will be able to get the context_element reference of current row in the event OnEnter.

Try the below code:


               data lo_element type ref to if_wd_context_element.

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

               if    lo_element is bound.

                    lo_element->set_selected( flag = abap_true ).

               endif.

Note: this selects the current row on which the OnEnter event occurred. if you keep pressing ENTER key on multiple rows, you would see that all those rows gets selected. For making context node to accept multiple row selection ... you should set the SELECTION : 0....n in the context node of the table. otherwise, run time error occurs

if your requirement is to select only one row at any case, then try the below code


          data lo_element type ref to if_wd_context_element.

          data lo_node type ref to if_wd_context_node.

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

               if    lo_element is bound.

                    lv_index = lo_element->get_index( ).

                    lo_node = lo_element->get_node( ).

                   

                    lo_node->SET_LEAD_SELECTION_INDEX( index = lv_index ).

               endif.

Hope this helps you.

Regards,

Rama

Message was edited by: Ramakrishnappa Gangappa

former_member184578
Active Contributor
0 Kudos

Hi,

Yes, You can add in the same event handler method of onEnter. as mentioned, use set_lead_selection_index( ) method to select the particular row.

Regards,

Kiran

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Guys,

I wanted to thank you all for the support. The information was really helpful.

Btw the logic works fine with wd_assist->get_sales_org_data( context_element ).

The thing was that only some certain sales org were triggering that method and I was using wrong testing data.

Cheers and have a great day ahead!


Best regards,

Elena

Former Member
0 Kudos

Thank you All for your support.

I have added the following syntax:

   data: lo_element type ref to if_wd_context_element,
     lo_node type ref to if_wd_context_node,
      lv_index  TYPE i.

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


if    lo_element is bound.
  lv_index = lo_element->get_index( ).
lo_node = lo_element->get_node( ).
lo_node->SET_LEAD_SELECTION_INDEX( index = lv_index ).
endif.


It does select each row at the enter action but now it's not bringing up the sales org data.


wd_assist->get_sales_org_data( context_element ).


This line of code seems to be bypassed somehow.


Any suggestions?


I already tried changing the position where this gets called but still the line is skipped.


Best regards,

Elena

ramakrishnappa
Active Contributor
0 Kudos

Hi Elena,


wd_assist->get_sales_org_data( context_element ).

Try this:

wd_assist->get_sales_org_data( lo_element ).


It seems that context_element reference is not filled and hence you are not able get the sales data. try passing lo_element.


Hope this helps you.


Regards,

Rama


Former Member
0 Kudos

Hi Ramakrishnappa,

I tried it also this way. Still won't populate the sales org data.

I have to mention that before I added the code it was fetching the data using the context_element.

Thank you.

Elena

ramakrishnappa
Active Contributor
0 Kudos

Hi Elena,

Please set an external breakpoint at the line and check inside the method, if any conditions are not satisfied to fetch the required data.

Also, check if you comment the code of setting rows as selected, your data gets populated?

Regards,

Rama

Former Member
0 Kudos

Hi Ramakrishnappa,

Thank you
This is exactly what I did to notice that some sales org id's don't trigger my method.

Regards,

Elena

ramakrishnappa
Active Contributor
0 Kudos

Thats good to know

Please close the discussion by marking answers as helpful / correct answers if so.

Regards,

Rama