Skip to Content
avatar image
Former Member

Getting Row Number in a table

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 ?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    Oct 16, 2008 at 08:48 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 07, 2008 at 10:31 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      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