cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Row Number in a table

Former Member
0 Kudos

I have a table with editable input fields with 5 columns. I have used an event (if we press ENTER) for the input field in all columns. The event is getting triggered. Its fine. But say ex: I have pressed ENTER on column 08 , Row 3, then how to capture that row/cell ?

In short how to capture the row number on pressing ENTER on a cell of a table ?

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Manjunath,

Below is the solution to try capture the row number & column name of the cell in which the user has pressed enter upon.

Say suppose I have only 2 columns in my table with ID's C1 & C2. (So I also have only 2 attributes "ONE" & "TWO" under the node "NODE" which am using to bind to the table.) In the WDDOINIT method I bind an internal table with all default values to the table.

method WDDOINIT .
  data: lr_node type ref to if_wd_context_node,
        lt_node type ig_componentcontroller=>elements_node,
        wa_node type ig_componentcontroller=>element_node.

lr_node = wd_context->get_child_node( name = 'NODE' ).

do 5 times.
  wa_node-one = '0'.
  wa_node-two = '0'.
  append wa_node to lt_node.
enddo.

lr_node->bind_table( new_items = lt_node ).
endmethod.

Now coming to the main part i.e, handling the enter action of the user.

method ONACTIONONENTER .
DATA: lr_element TYPE REF TO if_wd_context_element,
      lv_column_name type string,
      lv_row_number type i value 0.

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

  lv_column_name = wdevent->get_string( name = 'ID' ).

  lv_row_number = lr_element->get_index( ).

endmethod.

Now in the end lv_column_name would come up with the column name i.e, C1/C2 and lv_row_number would contain the position of the cell number under that particular column. Hope that this helps meet your desired task.

Regards,

Uday

Former Member
0 Kudos

Thanks for the solution. I too done the same way. As i have done a small mistake i got error.

Answers (1)

Answers (1)

Former Member
0 Kudos

the row is provided by the lead select of the node which is bound to the table.

lo_nd_node = wd_context->get_child_node( name = "your context node" )

data lv_indext type i.

i = lo_nd_node->get_lead_selection_index( ).

the coloumn you might get when using the event parameter of the enter action there is a parameter ID which delivers the id of the cell editor (input field)

have fun

stefan

Former Member
0 Kudos

Hi Stefan,

Thanks for the reply.

I have used your coding. I have selected the first row. and i got output of that statement as 2-

Cant we do this with out lead selection option ?

Former Member
0 Kudos

-2 is the place holder stating that no row is selected

probably you have set leadselection to none....

if you do not want to show lead select, goto tyble properties enable rowSelectable.... and setselectionMode to none

I think that should work.

or do you need sth else?

Former Member
0 Kudos

Hi Stefan,

I have checked the rowSelectable option and made the setselectionMode to None at the table properties. Even then the same result.

uday_gubbala2
Active Contributor
0 Kudos

Hi Manjunath,

You need to checkmark the rowSelectable property & set the selectionMode to Single. But then again you get the row number only if the user does a lead selection before pressing enter on any cells in that row. Also I couldn't obtain the cell number by using the WDEVENT parameter. It just returns the id of the column in which the user had pressed enter. Stefan please suggest how we can proceed using the WDEVENT.

Regards,

Uday

Former Member
0 Kudos

Hi,

As per the requirement, user has to enter the remarks on the cell of the table. So can we use Context Menu option ? i mean on right click of the mouse, can we trigger a POP-UP ? Is this possible ?

Former Member
0 Kudos

you can use context menu in table as yu would without. means if you have text view in table, you can define context menu at design time

probably that is what you mean with pop up, but you can also add pop up functionality when using link to action or something like that

regards

stefan