cancel
Showing results for 
Search instead for 
Did you mean: 

Set Cursor to next row Field in Table

Former Member
0 Kudos

Hi Experts,

I have a requirement in WDA table, when user click on Enter button from key board, cursor should move to the next row in table and without clicking on that columns user should type the message,

Right now user is able to type the message only after clicking on that cell.

Please guide me

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Explanation in Details;

I have 1 node in my context,

I use this node in table on layout

In table I put input fields and bind them to the context.

On input field marked in the above image, onenter event associated "MOVECUSROR"

Coding for MOVECURSOR as below

data: LO_NODE    type ref to IF_WD_CONTEXT_NODE,

         LO_ELEMENT type ref to IF_WD_CONTEXT_ELEMENT,

         LO_RUNTIMEAPI       type ref to IF_WD_VIEW_CONTROLLER,

         lv_index type I.

    LO_NODE   = WD_CONTEXT->GET_CHILD_NODE( 'DIA' ).

lv_index = lo_node->GET_LEAD_SELECTION_INDEX( ) ." Assuming lead selection is not set to next row on enter action in the input field.

lv_index = lv_index + 1. "if the lead selection is set next row after on enter event just remove lv_index

   lo_node->move_next( ).

   LO_ELEMENT = LO_NODE->GET_ELEMENT( lv_index ).

   LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).

   LO_RUNTIMEAPI->REQUEST_FOCUS( ATTRIBUTE = 'ICDDESC' CONTEXT_ELEMENT = LO_ELEMENT ).


Field in my context is 'ICDDESC' on which I am pressing enter.


Please guide.


-Regards

Rohit


harsha_jalakam
Active Contributor
0 Kudos

Hi Rohit,

Can you please check the node name, because from the screenshot I am able to see that node name is more than 3 characters, but in the coding, it is only 3 characters. Since it is not throwing a dump, I guess you are referring to other node with same attribute.

Regards,

Harsha

Former Member
0 Kudos

it is DIAGNOSE

Former Member
0 Kudos

I am referring as

LO_NODE   = WD_CONTEXT->GET_CHILD_NODE( 'DIAGNOSE' ).

lv_index = lo_node->GET_LEAD_SELECTION_INDEX( ) ." Assuming lead selection is not set to next row on enter action in the input field.

lv_index = lv_index + 1. "if the lead selection is set next row after on enter event just remove lv_index

   lo_node->move_next( ).

   LO_ELEMENT = LO_NODE->GET_ELEMENT( lv_index ).

   LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).

   LO_RUNTIMEAPI->REQUEST_FOCUS( ATTRIBUTE = 'ICDDESC' CONTEXT_ELEMENT =LO_ELEMENT ).


harsha_jalakam
Active Contributor
0 Kudos

Hi Rohit,

Please check with following code.

LO_NODE   = WD_CONTEXT->GET_CHILD_NODE( 'DIAGNOSE' ).

lv_index = lo_node->GET_LEAD_SELECTION_INDEX( ) .

lv_index = lv_index + 1.

LO_NODE->SET_LEAD_SELECTION(  lv_index ).

   LO_ELEMENT = LO_NODE->GET_ELEMENT( ).

   LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).   LO_RUNTIMEAPI->REQUEST_FOCUS( ATTRIBUTE = 'ICDDESC' CONTEXT_ELEMENT =LO_ELEMENT ).



Thank You,

Harsha

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks Harsha,

LO_NODE->SET_LEAD_SELECTION(  lv_index ).  this is giving me error , so I use

lo_node->set_lead_Selection_index( index = lv_index ).

And working fine.


Thanks for the kind help.


I am closing this.


-Regards

Rohit


harsha_jalakam
Active Contributor
0 Kudos

Please mark as correct and close the thread.

ramakrishnappa
Active Contributor
0 Kudos

Hi Rohit,

While setting cursor, you no need to set lead index of table. Also no need to get node reference explicitly, as you can just get it from context element of current cell.

Please refer the below code snippet


   DATA view_ctrl  TYPE REF TO if_wd_view_controller.

   DATA lo_element TYPE REF TO if_wd_context_element.

   DATA lo_node    TYPE REF TO if_wd_context_node.

   DATA lv_index   TYPE i.

   "get current context element

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


   "get node from context element

   lo_node = lo_element->get_node( ).

   "get current line

   lv_index = lo_element->get_index( ).

   lv_index = lv_index + 1.

   "Get next context element

   FREE lo_element.

   lo_element = lo_node->get_element( index = lv_index ).

   IF lo_element IS BOUND.

    

   view_ctrl = wd_this->wd_get_api( ).

     view_ctrl->request_focus(

    EXPORTING

         context_element lo_element   " Context Element

         attribute       'ICDDESC'   " Context Attribute

     ).

   ENDIF.

Hope this simplifies your work.

Regards,

Rama

Former Member
0 Kudos

Hi Rohit,

I have tried your code, it doesn't show any error and the same time nothing happened.

DATAlo_node TYPE REF TO if_wd_context_node,

             lo_element TYPE REF TO if_wd_context_element,

             lo_runtimeapi TYPE REF TO if_wd_view_controller,

             lv_index TYPE i.

   lo_node   = wd_context->get_child_node( name = 'TABLE').

   lv_index = lo_node->get_lead_selection_index( ) .

   lv_index = lv_index + 1.

   lo_node->set_lead_selection_index( index = lv_index ).

   lo_element = lo_node->get_element( ).

   lo_runtimeapi = wd_this->wd_get_api( ).

   lo_runtimeapi->request_focus( attribute = 'P_ID' context_element = lo_element ).

here my node name is 'table' and its corresponding attribute is P_ID. I don't know where I am doing the mistake. If you found, say me the same.

thanks in advance.

regards,

kishore

harsha_jalakam
Active Contributor
0 Kudos

Hi Rohit,

Please check the following code.

data: LO_NODE    type ref to IF_WD_CONTEXT_NODE,

        LO_ELEMENT type ref to IF_WD_CONTEXT_ELEMENT,

        LO_RUNTIMEAPI       type ref to IF_WD_VIEW_CONTROLLER,

        lv_index type I.

   LO_NODE   = WD_CONTEXT->GET_CHILD_NODE( 'TAB_DATA' ).

lv_index = lo_node->GET_LEAD_SELECTION_INDEX( ) ." Assuming lead selection is not set to next row on enter action in the input field.

lv_index = lv_index+1. "if the lead selection is set next row after on enter event just remove lv_index

  LO_ELEMENT = LO_NODE ->GET_ELEMENT( lv_index ).

  LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).

  LO_RUNTIMEAPI->REQUEST_FOCUS( ATTRIBUTE = 'CITYFROM' CONTEXT_ELEMENT = LO_ELEMENT ).

Method REQUEST_FOCUS_ON_VIEW_ELEM of if_wd_view, can also be used to place cursor on particular input field.

Regards,

Harsha

Former Member
0 Kudos

Hi harsha,

I checked with you code,

It is changing the LEAD SELECTION only, but not placing cursor on the editable column to edit the value.

I need to click, then I can change the value, please check attached screen shot for reference

Check my cursor is in the same line where I entered "Hello", but it should be on line of lead selection

Below is the UI elements of  my table, in attributes I am using "DIAG_ICDDESC"

Code is as follows

LO_ELEMENT = LO_NODE->GET_ELEMENT( lv_index ).

   LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).

   LO_RUNTIMEAPI->REQUEST_FOCUS( ATTRIBUTE = 'DIAG_ICDDESC' CONTEXT_ELEMENT = LO_ELEMENT ).


Please guide me if I am wrong.


-Regards

Rohit

harsha_jalakam
Active Contributor
0 Kudos

Hi Rohit,

Can you try with the following code.

I guess the code is not pointing to the new element(next row), try passing the correct element

LO_ELEMENT = LO_NODE->GET_ELEMENT( lv_index + 1 ).

   LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).

   LO_RUNTIMEAPI

->REQUEST_FOCUS( ATTRIBUTE = 'DIAG_ICDDESC' CONTEXT_ELEMENT = LO_ELEMENT ).

Thank You,

Harsha

Former Member
0 Kudos

Hi Harsha,

I have already incremented the lv_index values before passing to LO_ELEMENT.

lv_index = lv_index + 1.

   LO_ELEMENT = LO_NODE->GET_ELEMENT( lv_index ).

   LO_RUNTIMEAPI = WD_THIS->WD_GET_API( ).

   LO_RUNTIMEAPI->REQUEST_FOCUS( ATTRIBUTE = 'DIAG_ICDDESC' CONTEXT_ELEMENT = LO_ELEMENT ).

But it is not placing the cursor to correct cell.

Please guide If I am wrong.

-Regards

Rohit

ramakrishnappa
Active Contributor
0 Kudos

Hi Rohit,

Your code looks okay, but make sure that you are using the correct attribute name from the context node.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

I am using 'DIAG_ICDDESC' please guide me if I am wrong.

-Regard

Rohit

ramakrishnappa
Active Contributor
0 Kudos

Hi Rohit,

It should work. I suspect that you are updating context data somewhere after setting focus to the element. Check if any place which alters table data.

Regards,

Rama

Former Member
0 Kudos

Hi Rama,

Where should I code this.,

right now I coded it on "ONENTER" event of input field.

-Regards

Rohit

harsha_jalakam
Active Contributor
0 Kudos

Hi Rohit,

Can you please share the total code of the on enter event.

Regards,

Harsha

ramakrishnappa
Active Contributor
0 Kudos

Ya it should be fine.

With the code you are using the lead selection is not suppose to change , as you are not setting it here.

Please share the snap shot of your context node.

Regards,

Rama