cancel
Showing results for 
Search instead for 
Did you mean: 

Add row based on previous row in table control?

Former Member
0 Kudos

Dear all,

I have a table control with some rows. Every row contains one button. On button click i want to add another row with dirrerent data. I want to add content based on button text or another columns (ex text views text,) based on this text view, I have to add row. One button can click any no of times. On every click i want to add row, but desired position and content should be based on button click. Any help in doing this??

Cheers,

Venkys.

Accepted Solutions (0)

Answers (2)

Answers (2)

gill367
Active Contributor
0 Kudos

Refer to these old threads referring this table and button problem.

and for the current scenario what you can do is ...

in the eventhandler of the button click .

find out the row number by using the code to read index.

then based upon that add the element in the node at the desired position.

finding the row number




  data indx type i.
      DATA lo_el TYPE REF TO if_wd_context_element.
      lo_el = wdevent->get_context_element( 'CONTEXT_ELEMENT' ).
 indx = lo_el->get_index( ). 

and the adding the element at the desired position say n



    DATA lo_nd_zdealer TYPE REF TO if_wd_context_node.

    lo_nd_zdealer = wd_context->get_child_node( name = 'DEALER' ).
 data ls_str type  wd_this->element_dealer.
   ls_str-id = '00023445'.
   ls_str-name = 'sarbjeet'.
   ls_str-location = 'hosiarpur'.
   ls_str-status = '0001'.

   lo_nd_zdealer->bind_structure( new_item = ls_str
   set_initial_elements = abap_false
   index = n
    ).

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Venky,

This type of questions are answered lately lots of times. Please go through the Forum before posting it.

The logic would be

1. OnAction button get the wdevent parameters like context_element,id,Index .

2. Create a new context element and fill data based on your logic.

3. insert it to t the node on desired index

Former Member
0 Kudos

Hi Basakaran,

ya, i tried like that using wdevent and index,

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

index = lo_el->get_index( ).

But, here problem is.. suppose 3 rows are there. if i click on 1st or 2 or 3 row it will create 4th row.

If i click on th row again i want to add another row, but i dont know this 4th row is which one(it is created by clicking1 or 2 or 3).

How i come to know which button is triggered. So thats why i am asking any way is there by using button text or something else.

cheers,

Venkys.

Edited by: venkys on Feb 2, 2011 10:46 AM

Former Member
0 Kudos

>

> Hi Basakaran,

>

> ya, i tried like that using wdevent and index,

>

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

> index = lo_el->get_index( ).

>

> But, here problem is.. suppose 3 rows are there. if i click on 1st or 2 or 3 row it will create 4th row.

> If i click on th row again i want to add another row, but i dont know this 4th row is which one(it is created by clicking1 or 2 or 3).

> How i come to know which button is triggered. So thats why i am asking any way is there by using button text or something else.

>

>

>

> cheers,

> Venkys.

>

> Edited by: venkys on Feb 2, 2011 10:46 AM

I do not understand your requirement.

The index say on which row the button is being clicked so you know that if it is 1 or 2 or 3 or 4.

What am i missing in your problem ?