cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the focus in a Table Control

Former Member
0 Kudos

Hello Experts,

I have a simple Table control in my screen . I want to know under which column my cursor is ? Basically i want to get the focus the table control . How can i achieve this ?

Thanks

Vivek

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

If there is an attribute 'user_group_name'then to set focus for that field then

in wddomodifyview() write the following code.

DATA:

lo_node TYPE REF TO if_wd_context_node,

lo_element TYPE REF TO if_wd_context_element,

lo_view_contr TYPE REF TO if_wd_view_controller.

lo_node = wd_context->get_child_node( name = wd_this->wdctx_initial_screen ).

lo_element = lo_node->get_element( ).

  • Set Focus on Field 'User Group'

IF first_time = abap_true.

lo_view_contr = wd_this->wd_get_api( ).

lo_view_contr->request_focus(

EXPORTING context_element = lo_element

attribute = 'USER_GROUP_NAME' ).

ENDIF.

Former Member
0 Kudos

If there is an attribute 'user_group_name'then to set focus for that field then

in wddomodifyview() write the following code.

DATA:

lo_node TYPE REF TO if_wd_context_node,

lo_element TYPE REF TO if_wd_context_element,

lo_view_contr TYPE REF TO if_wd_view_controller.

lo_node = wd_context->get_child_node( name = wd_this->wdctx_initial_screen ).

lo_element = lo_node->get_element( ).

  • Set Focus on Field 'User Group'

IF first_time = abap_true.

lo_view_contr = wd_this->wd_get_api( ).

lo_view_contr->request_focus(

EXPORTING context_element = lo_element

attribute = 'USER_GROUP_NAME' ).

ENDIF.

baskaran00
Active Participant
0 Kudos

Vivek,

Basically the default focus of the table will be the lead selection and it doesnot focus to any particular column.

But u can set the focus to particular column in the table control.

Ref the below code:

DATA lo_api TYPE REF TO if_wd_view_controller.

lo_api = wd_this->wd_get_api( ).

lo_api->request_focus(

context_element = <<element name>>

attribute = '<<attribute name>>' ).

Hope it will resolve ur problem.

Thanks,

Router

Former Member
0 Kudos

Hello Router ,

I do not want to set the focus , I want to get focus . User can click on any cell in the table and then press a button in the toolbar . Now in the event handler of the button i want to under which column User has set the focus .

I hope , I am clear now .

Thanks for your help

Regards

Vivek

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>

> Hello Router ,

> I do not want to set the focus , I want to get focus . User can click on any cell in the table and then press a button in the toolbar . Now in the event handler of the button i want to under which column User has set the focus .

> I hope , I am clear now .

> Thanks for your help

> Regards

> Vivek

An yet you keep getting suggestions of how to set the focus. I looked through the API documentation and I don't see anything that would suggest you can request to see where the current focus is. Perhaps someone might still come along with a solution, but my hopes wouldn't be too high at this point. I can pass the requirement onto Product Definition, as the use case does seem interesting. Perhaps it is something we have even considered in the past.

But for now, there might be a better way to solve your problem. It will probably mean redesign the interaction. What exactly are your requirements? Do you need to be able to get the data in a particular cell of table when a button is clicked? Just throwing out some ideas here, but maybe just use the lead selection to select the row, but then have a button choice to choose the action associated with the column you want. A hack for sure - but it might work. Also it doesn't help you right now, but in the near future update to NetWeaver 7.0, WDA does have a onColSelect event for the table.

Former Member
0 Kudos

Hi,

You can listen to onSelect event.

I thnk thatwill do.

Regards,

Sumit