on 01-28-2011 12:32 PM
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.
sorry by mistake i put that..
instead of abap_true
abap_false should be the value of parameter set_initial elements
thanks
sarb
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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
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.
>
> 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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.
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
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.