cancel
Showing results for 
Search instead for 
Did you mean: 

It is possible to binding different nodes with single table?

Former Member
0 Kudos

Hi All

I have NODE1 and NODE2. Created seperately.

i am creating a table using NODE1. I created two rows in table on button click. Now one of the table column contains button. Example col1. Now on COL1 click i want to add one more row of NODE2. It is possible to create like this?

Thanks,

Kris.

Accepted Solutions (1)

Accepted Solutions (1)

gill367
Active Contributor
0 Kudos

sorry by mistake i put that..

instead of abap_true

abap_false should be the value of parameter set_initial elements

thanks

sarb

Former Member
0 Kudos

Hi Sarbjeet

Now adding new row with new content, but on every row i have a button, based on that button click i want to add new content, but here i am getting same content for all buttons. How to do this?? I removed lead selection at context level. If i check based on lead selection means i have to select that row right?, but i am not selecting row, i am just clicking the button. Please help.

Thanks,

Kris.

gill367
Active Contributor
0 Kudos

HI

You can get the index of the row from where the button has been clicked by using the get_index method of the element.

Use this sample code in the eventhandler to know the index of the row.

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( ).

thanks

sarbjeet singh

Former Member
0 Kudos

Hi Sarbjeet

data: lr_node type ref to if_wd_context_node,

ls_data type if_main_view=>element_segment,

lt_data type if_main_view=>elements_segment.

data indx type i.

DATA lo_el TYPE REF TO if_wd_context_element.

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

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

      • At Context_element - I given context Element here using for button is 'BUTTON'

I tried with CONTEXT_ELEMENT namei.e.,(BUTTON), with node(NODE) and with NODE.CONTEXT_ELEMENT(NODE.BUTTON), I tried all ways it is giving dump. Access Null Object.******

indx = lo_el->get_index( ).

ls_data-button = 'Button2'.

ls_data-Name1 = 'Name2'.

APPEND LS_DATA TO LT_dATA.

LR_NODE->BIND_TABLE(

NEW_ITEMS = LT_DATA

SET_INITIAL_ELEMENTS = ABAP_FALSE ).

Thanks,

Kris.

gill367
Active Contributor
0 Kudos

HI

dont give anything else just give 'CONTEXT_ELEMENT' there.

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

keep it like that only. and try.

thanks

sarbjeet

Answers (1)

Answers (1)

Former Member
0 Kudos

>

> Hi All

>

> I have NODE1 and NODE2. Created seperately.

>

> i am creating a table using NODE1. I created two rows in table on button click. Now one of the table column contains button. Example col1. Now on COL1 click i want to add one more row of NODE2. It is possible to create like this?

>

>

>

>

> Thanks,

> Kris.

If you want to add one more row , you can just add or create a node_element to the Node1, fill the data from Node2 to the node_element.

Is your node2 has 0..1 cardinality then ?.

You have to have a clear understanding and design purpose why do you want to have 2 nodes ? where there are getting data from. How there are related to each other ? are they having same line type etc.

Former Member
0 Kudos

Hi Baskaran

Thanks for your reply,

Actually what i am trying to do is, i filled table with 2 rows on button click. In that table one column contains button, when i click on this button i want to add one more row. For this i am reading same row and filling data, but it created new row, i mean refreshed old and updated with new row. But i want to add new row, i.e., as third row in the table. How to fill new row with new data??

method onactionbutton

DATA LR_NODE TYPE REF TO if_wd_context_node.

DATA ls_data TYPE wd_this->element_node.

data lt_data type wd_this->elements_node.

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

ls_data-button1 = Button1.

ls_data-name = 'New Name'.

APPEND LS_DATA TO LT_dATA.

LR_NODE->BIND_TABLE( LT_DATA ).

endmethod. ---this code i am using to add new row with new data.

Thanks,

Kris.

Edited by: kissnas on Jan 29, 2011 5:45 AM

gill367
Active Contributor
0 Kudos

Instead of

LR_NODE->BIND_TABLE( LT_DATA ).

use

LR_NODE->BIND_TABLE(
NEW_ITEMS = LT_DATA
SET_INITIAL_ELEMENTS = ABAP_TRUE 
)

THANKS

sarbjeet singh

Former Member
0 Kudos

Hi

try this

lr_node->bind_element( new_item = ls_data set_initial_elements = abap_false ).

thanks,

venkat

Edited by: venkat1011 on Jan 29, 2011 6:54 AM

Former Member
0 Kudos

Hi SArbjeet

Both are giving same..

In view i have a button, in button action i have this code

DATA LR_NODE TYPE REF TO if_wd_context_node.

DATA ls_data TYPE wd_this->element_node.

data lt_data type wd_this->elements_node.

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

ls_data-button1 = 'Add '.

ls_data-name = 'Name1'.

APPEND LS_DATA TO LT_dATA.

ls_data-button1 = 'Add Sub'.

ls_data-name = 'Name2'.

APPEND LS_DATA TO LT_dATA.

LR_NODE->BIND_TABLE( LT_DATA ).

It creating two records. on button click of ADD, code is like this

DATA LR_NODE TYPE REF TO if_wd_context_node.

DATA ls_data TYPE wd_this->element_node

data lt_data type wd_this->elements_node.

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

ls_data-button = 'SUB.'

ls_data-name = 'name3'.

APPEND LS_DATA TO LT_dATA.

  • LR_NODE->BIND_TABLE( LT_DATA ).

LR_NODE->BIND_TABLE(

NEW_ITEMS = LT_DATA

SET_INITIAL_ELEMENTS = ABAP_TRUE ).

This code is adding one record, but instead of old records, but i want this record as third one. how to do this???

My output is like this..

After first button action 2 row like

ADD(button) - Name(text view) - value(input).

SUB(button) - Name1(tv) - Value(ip).

After clicking ADD button at first row i want output like this

ADD(button) - Name(text view) - value(input).

SUB(button) - Name1(tv) - Value(ip).

ADD1(button) - Name2(TV) - value(ip).

but i am getting only--- ADD1(button) - Name2(TV) - value(ip).

Thanks,

Kris.

Former Member
0 Kudos

Hallo ,

If i understand you correctly, you need to add records just below the row where the button is clicked.

For that the rough logic would be.

Get the Index

-


1. OnButtonAction - get the parameter Id,Context_ELEMENT (if you do not have them, you can create them as import parameters Id type string, context_element type ref to if_wd_context_element ).

I am not sure if table returns a index of the table when you press a button. What you can do is use the context_element to set the lead_selection and get_lead_selection_index to get the index.

create new structure

-


2.Use node->bind_element(

new_item = <structure you want to insert>

SET_INITIAL_ELEMENTS = abap_false

index = lv_index+1 "lv_index is the index you calculated in step-1.

).

Edited by: Baskaran Senthivel on Jan 29, 2011 8:27 AM