cancel
Showing results for 
Search instead for 
Did you mean: 

Binding the new row to the top of the table

Former Member
0 Kudos

Hi Friends,

i habe a table and a button called Insert Row. If I click on this button, one row will be added to the table after the last row. I didn't find a way to jump to the added row after clicking on the Insert Row button.

I habe read in one thread here in WD Forum that as a work around I can add the new row to the top of the table using BIND_ELEMENT method.

So I tried to use BIND_ELEMENT instead of BIND_TABLE like this:

*  lo_nd_table->bind_table(  new_items = lt_table
*   index = 0 ).

* to add the new line on the top
  lo_nd_table->bind_element(
  new_item = lt_table
  set_initial_elements = abap_false
  index = 0 ).

but now i get this error message:

Dynamic type conflict when assigning references

Does anyone has an Idea?

Thank you

Regards

Haleh

Accepted Solutions (1)

Accepted Solutions (1)

uday_gubbala2
Active Contributor
0 Kudos

Hi Haleh,

Give it a try with the below code snippet. I have just given it a try and it works fine:

METHOD onactioninsert .
  DATA: lr_node TYPE REF TO if_wd_context_node,
        lr_element TYPE REF TO if_wd_context_element.

 lr_node = wd_context->get_child_node( name = if_main=>wdctx_sflight ).
 lr_element =  lr_node->bind_element( set_initial_elements = abap_false
                                      new_item             = ls_data 
                                      index                = 1 ).
ENDMETHOD.

Regards,

Uday

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Uday, hi Chitrali,

thank you both for the answers. It works now with the index = 1.

I don't know why! Actually The first line has the index 0.

have a nice day

Kind regards

Haleh

Former Member
0 Kudos

Hi Haleh,

BIND_TABLE is used to add multiple rows to a context node with cardinality o-n or 1-n..

Whereas BIND_ELEMENT is used to add one row at a time to a context node...hence you need to populate a structure ls_table that you pass as an input to BIND_ELEMENT, and not lt_table .


*  lo_nd_table->bind_table(  new_items = lt_table
*   index = 0 ).
 
* to add the new line on the top
  lo_nd_table->bind_element(
  new_item = ls_table
  set_initial_elements = abap_false
  index = 0 ).

This should resolve the error you are getting.

Thanks.

Chitrali

Edited by: Chitrali Shah on Dec 3, 2008 12:31 PM

Former Member
0 Kudos

Hi Chitrali,

thank you very much for your answer. This is good I corrected the lt_table to ls_table and I don't get the error message anymore.

But i don't know why, the added row is still after the last row of the table. How can i add the new row as the first row in the table, that it could be visible immediately.

thank you

regards

Haleh

uday_gubbala2
Active Contributor
0 Kudos

Hi haleh set the index to 1. It would get displayed as the 1st row of your table.

Regards,

Uday

Former Member
0 Kudos

Hi Uday,

yes I tried above to say that I did this and the new line comes on the top, even though I still don't know why!

thanks again

regards, Haleh