cancel
Showing results for 
Search instead for 
Did you mean: 

Focus in table editable cell

pekka_pottonen
Participant
0 Kudos

Hi,

I have a table(not alv) with single editable cell as fifth cell. Now users want focus to be on that field when table opens and move to next editable cell once enter is pressed. How do I achieve this?

Regards

Pekka

Accepted Solutions (0)

Answers (2)

Answers (2)

gill367
Active Contributor
0 Kudos

hi pekka

Create an attribute of type ref to IF_WD_VIEW in tehe context. under the main context node itself. give its name as view.

write some code in the wddomodify.

like as shown below.


  if first_time eq abap_true.
 data node type ref to if_wd_context_node.
  data ele type ref to if_wd_context_eleMENT.
  node = wd_context->get_child_node( '<node name>' ).     "write your node name here which is used as data source for table
  ele = node->get_element( 1 ).
  DATA VEL TYPE REF TO IF_WD_VIEW_ELEMENT.
  VEL ?= lv_view->GET_ELEMENT( '<view ele id>' ).       "write the view element id of the fifth cell 's cell editor's id
  lv_view->REQUEST_FOCUS_ON_VIEW_ELEM(
  view_element = VEL
  CONTEXT_ELEMENT = ELE
  ).


  wd_context->set_attribute(
  name = 'VIEW'
  VALUE = VIEW

  ).
 endif.

and write the following code in the onenter eventhandler.


    DATA lv_view TYPE REF TO IF_WD_VIEW.

   WD_CONTEXT->get_attribute(
      EXPORTING
        name =  `VIEW`
      IMPORTING
        value = lv_view ).

    DATA INDX TYPE I.
    DATA EL TYPE REF TO IF_wD_CONTEXT_ELEMENT.
    EL = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT' ).
    INDX = EL->GET_INDEX( ).
    INDX = INDX + 1.

 data node type ref to if_wd_context_node.
  data ele type ref to if_wd_context_eleMENT.
  node = wd_context->get_child_node( '<node name>' ).     "write your node name here which is used as data source for table
  ele = node->get_element( INDX ).
  DATA VEL TYPE REF TO IF_WD_VIEW_ELEMENT.
  VEL ?= lv_view->GET_ELEMENT( '<view ele id>' ).       "write the view element id of the fifth cell 's cell editor's id
  lv_view->REQUEST_FOCUS_ON_VIEW_ELEM(
  view_element = VEL
  CONTEXT_ELEMENT = ELE
  ).

thansk

sarbjeet singh

pekka_pottonen
Participant
0 Kudos

Hi Sarbjeet,

Great, works fine. I had a different solution for the eventhandler, but this is ok.

(I´m trying to give points, but so far an error occurs. I will try again)

Regs,

Pekka

Former Member
0 Kudos

Hi Sarbjeet

Just wanted to say this was very helpful solution. I had the same challenge as Pekka and this worked perfectly.

(In wddomodify I had to change it slightly to make it work;

From:


VEL ?= lv_view->GET_ELEMENT( '<view ele id>' ).

  lv_view->REQUEST_FOCUS_ON_VIEW_ELEM(...

to:

VEL ?= view->GET_ELEMENT( '<view ele id>' ). 

view->REQUEST_FOCUS_ON_VIEW_ELEM(...

Best regards,

Gunnar


Former Member
0 Kudos

Hi Pekka,

Try using this method,

REQUEST_FOCUS or IF_WD_VIEW_CONTROLLER of IF_WD_VIEW_CONTROLLER or

REQUEST_FOCUS_ON_VIEW_ELEM of if_wd_view. It may helps you.

Thanks,

Kris.

Edited by: kissnas on Feb 8, 2011 8:11 AM