cancel
Showing results for 
Search instead for 
Did you mean: 

How to find out number of selected row in RowRepeater?

Former Member
0 Kudos

Hello,

could you help me with WebDynpro, please?

I need to delete selected row of RowRepeater:

I don´t know how to recognize what row has been selected.

Thank you.

Monika

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Monika,

LEAD SELECTION will not work for ROW REPEATER as it does in TABLE UI element.

Here is a solution,

In the action bound to your delete button add a new importing parameter called CONTEXT_ELEMENT of type IF_WD_CONTEXT_ELEMENT.

Ensure that you select the RefTo check box.

Do not use any other name for this parameter. Now, the appropriate row element will be available automatically during runtime by using this parameter.

Here is a sample code to delete the selected row based on this parameter

onactiondelete .


 
DATA: lo_node_country TYPE REF TO if_wd_context_node.

  lo_node_country
= wd_context->get_child_node( wd_this->wdctx_country ).


 
IF  context_element IS BOUND.
     lo_node_country
->remove_element( context_element ).
 
ENDIF.

ENDMETHOD.

onactiondelete .

Warm Regards,

Shibin
 







Former Member
0 Kudos

Hi Shibin!

Perfect!!!

Thank you very much!

It is really smart solution!

Thank you.

Monika

Former Member
0 Kudos

Hi,

Create a boolen type in your context node, the one  that is bound to the row repeater and bind it to a check box, place the check box either at the begining or end of each row.

This will allow you to select 1 or more rows for deletion.

On click of delete button, loop throught the node and delete selected rows.

Regards,

Shibin

Former Member
0 Kudos

Thank you Shibin,

but I would like to delete only one selected row by clicking on the button at the end of the row.

Rows can be selected with the same values.

I need to find out which row was selected. How could I recognize it?

Thank you.

Monika

former_member184578
Active Contributor
0 Kudos

Hi,

Have you tried the below code to get the index of the row. Write the below code in onAction of delete button.


   DATA lr_el_element TYPE REF TO if_wd_context_element.

   DATA lv_index TYPE i.


   lr_el_element = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).

    lv_index = lr_el_element->get_index( ).

lv_index will contain the deleted index.

Hope this helps u,

Regards,

Kiran

Former Member
0 Kudos

If the name of the node is 'ND_TASK_R'   then below code can be used:

Please replace 'ND_TASK_R' with the name of your node and then test.

DATA LO_ND_ND_TASK_R TYPE REF TO IF_WD_CONTEXT_NODE.
  DATA LO_EL_ND_TASK_R TYPE REF TO IF_WD_CONTEXT_ELEMENT.
  DATA LS_ND_TASK_R TYPE WD_THIS->ELEMENT_ND_TASK_R.

  LO_EL_ND_TASK_R = WDEVENT->GET_CONTEXT_ELEMENT( 'CONTEXT_ELEMENT').
  LO_ND_ND_TASK_R = LO_EL_ND_TASK_R->GET_NODE( ).

  LO_EL_ND_TASK_R->GET_STATIC_ATTRIBUTES(
  IMPORTING
    STATIC_ATTRIBUTES = LS_ND_TASK_R ).

Former Member
0 Kudos

Thank you Hitesh,

but I have problem with rows that are filled with the same values...

Is it possible to find out number (index) of selected row?

Thank you.

Monika