on 2009 Mar 09 7:42 AM
Hi,
I have a table UI element with data in it.
When i click on Add Row button, an empty row should get added in to the table UI element.
Can anybody help me out as to how to do this?
Regards,
Kanakaraj V A
Hi Kanakaraj,
In order to realise this functionality you would just have to bind an empty work area to your context node.
For example: I have a node by name SFLIGHT which am using to bind to a table on my layout. Try check the code snippet below for my button's action handler:
method ONACTIONADD_ROW .
data: wd_node type ref to if_wd_context_node,
wa_data type wd_this->element_sflight.
wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
wd_node->bind_structure( new_item = wa_data
SET_INITIAL_ELEMENTS = ABAP_FALSE ).
endmethod.
Its important to set SET_INITIAL_ELEMENTS to ABAP_FALSE otherwise all the rows of the table would get deleted & it would just contain the newly added row.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kanakaraj,
As a workaround you can try add the new record at the beginning of the table if you want by specifying the index while binding the structure:
wd_node->bind_structure( new_item = wa_data
index = 1
SET_INITIAL_ELEMENTS = ABAP_FALSE ).
I would in the meantime search and tell you know how you can append the row and also have the focus set over it.
Regards,
Uday
Hi Kanakaraj,
You can try proceed as follows. Your table has a property called FirstVisibleRow. This determines as to which row of the table should be visible to the user. By default it has a value of zero. So try as:
1) Bind the tables FirstVisibleRow to a context attribute which has a value 0 by default
2) When the user clicks on the add row button:
a) Get the count of total number of rows in the table
b) Set the value of attribute to which FirstVisibleRow is bound to count + 1
Check the code snippet below:
method ONACTIONADD_ROW .
data: wd_node type ref to if_wd_context_node,
wa_data type wd_this->element_sflight,
count type i.
wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
" Get the count of rows in the table
count = wd_node->get_element_count( ).
count = count + 1.
wd_node->bind_structure( new_item = wa_data
SET_INITIAL_ELEMENTS = ABAP_FALSE ).
" Set the value of context attribute to which FirstVisibleRow is bound to
wd_node = wd_context->get_child_node( name = 'SCROLL' ).
wd_node->set_attribute( exporting name = 'FIRSTVISIBLEROW'
value = count ).
endmethod.
Regards,
Uday
Hi Kanakaraj,
This is the complete code that you should use for adding a record at the beginning of the table:
method ONACTIONADD_ROW .
data: wd_node type ref to if_wd_context_node,
wa_data type wd_this->element_sflight,
count type i.
wd_node = wd_context->get_child_node( name = 'SFLIGHT' ).
count = wd_node->get_element_count( ).
count = count + 1.
wd_node->bind_structure( new_item = wa_data
index = 1
SET_INITIAL_ELEMENTS = ABAP_FALSE ).
endmethod.
This code is working fine for my component. Just check it out.
Regards,
Uday
Hi,
Step1: read the Table properties (Table name) by using if_wd_view try it in wdDoModifyView.
Step2: by using class cl_wd_table you can add new row to your table. (in SE24 you can check class properties)
Put this code in your conditions for example when you click the button a new row has to add to the table
Best Regards
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi kanakaraj,
Try out this...
Data : node_table type ref to if_wd_context_node,
elem_table type ref to if_wd_context_element.
node_table = wd_context->get_child_node( 'TABLE' ).
elem_table = node_table->create_element( ).
node_table->bind_element( new_item = elem_table set_initial_elements = abap_false ).
Hope this helps..
Thanks,
Mugundhan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
70 | |
10 | |
10 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.