on 02-04-2009 6:30 PM
Hi gurus,
I want to edit a single row that is selected in the Table UI element and that modification shld get updated in the database table,
I have searched the forum and found tht a couple of threads, i tried them but couldnt succeed..
Please provide me your valuable inputs for getting this done...
thanks in advance
Regards,
Ravikanth
Hi Ravi,
Tyr this
In your view layout add a new UI element Table.
In table properties click on Datasource and select your context node.
Right click on the table UI element under rootuielementcontainer and select CREATE BINDING.
Select the context node and you will see all the fields as a list, for each field which you want to see in the UI and bind it with your context select for example: inputfield and (name of the property to be bound) as Value and make sure you select the option binding.
You can now assign your action and in this method get your selected fields.
OR Create a button and in this button properties assign an action in that method do the following:
DATA: lr_node TYPE REF TO if_wd_context_node,
lt_table TYPE (your table type).
FIELD-SYMBOLS <items> TYPE ANY TABLE.
lr_node = wd_context->get_child_node( 'YOUR_CONTEXT' ).
ASSIGN lt_table TO <items>.
lr_node->get_static_attributes_table(
IMPORTING
table = <items> ).
MOVE <items> TO lt_matrix.
If helpful points would be appreciated.
Thanks & Regards,
Abhinav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi abhinav,
I have created the table and was able to see all the records from my standard table.
my requirement is initially the rows sholud be displayed in textview and when the user selects a row only tht row shld be editable and once we edit the values they shld get updated in the standard table as well..
Please help in detail coding...
regards
ravikanth
Hi Ravi,
You can try proceed as follows.
Suppose you are displaying 3 columns col1, col2 & col3 in your table then create an additional attribute at context level say ATTR4 of type WDY_BOOLEAN. And specify the default value for this attribute at context level as true i., X . So now when you display the data in the table all rows have an additional boolean attribute ATTR4 which has a value of true. Now go to the individual cell editor of each table column and bind its readOnly property to this created attribute ATTR4. So now the tables row would be editable/non-editable based on the value contained in ATTR4.
Now create an event on leadSelection for the table and within this eventhandler:
1) Get the index of the row selected by the user.
2) Modify the value of context attribute ATTR4 for this particular index to a blank value i.e, false.
ex: If table has 10 rows and user has clicked on the 3rd row then you will need to modify the 3rd index value of ATTR4 at context node.
Since the table rows readOnly property are bound to this ATTR4, the 4th row would be having the value as false which would result in only the 4th row being displayed as editable. Hope this helps resolve your problem.
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 Ravi,
My server isn't working at the moment so am unable to paste the code for you. It isn't that hard though.
1) First obtain the reference of the context node that you are using for binding to your table using the GET_CHILD_NODE method of IF_WD_CONTEXT_NODE into an reference variable say wd_context.
2) Next use the GET_LEAD_SELECTION_INDEX method of IF_WD_CONTEXT_NODE using the reference variable wd_context obtained above.
3) Finally to modify the context attributes value for the specified index then you can proceed as follows. First get the reference of the attribute at desired index by using the GET_ELEMENT. Suppose you want to modify the boolean attributes value for the 3rd row then pass index = 3 while calling GET_ELEMENT to get the desired reference. Save the reference into a reference variable say wd_element of type IF_WD_CONTEXT_ELEMENT.
Now use the obtained reference wd_element to call its SET_ATTRIBUTE method. Specify the attribute name as the boolean attribute & the value as abap_false.
Regards,
Uday
Hi,
Create one attribute type wdy_boolean to your context node which is binded to to table UI element.
Say the node name is node and the attribute name is edit.
create binding the table with the node without the edit attribute.
set the default value of the edit attribute to abap_false so that your entire table comes in read only mode.
Now do the following coding in the OnLeadSelection event of table.
DATA lo_nd_node TYPE REF TO if_wd_context_node.
DATA lo_el_node TYPE REF TO if_wd_context_element.
DATA:ls_node TYPE wd_this->element_node,
it_node TYPE wd_this->elements_node,
index TYPE i.
navigate from <CONTEXT> to <node> via lead selection
lo_nd_node = wd_context->get_child_node( name = wd_this->wdctx_node ).
***************
lo_nd_node->get_static_attributes_table( IMPORTING table = it_node ).
LOOP AT it_node INTO ls_node.
IF ls_node-iso = 'AE'.(some condition)
ls_node-edit = abap_true.
ELSE.
ls_node-edit = abap_false.
ENDIF.
MODIFY it_node FROM ls_node TRANSPORTING edit.
lo_nd_node->bind_structure( set_initial_elements = abap_false
new_item = ls_node ).
ENDLOOP.
index = lo_nd_node->get_lead_selection_index( ).
lo_nd_node->bind_table( it_node ).
lo_nd_node->set_lead_selection_index( index = index ).
IF helpful give points.
thanks,
Subhasis.
Hi Ravi,
I am new to WebDynpro as well but try this.
In the table event onSelect (in properties) add a new event-> row_selection
In the method of this action get the index of row selected
how to get the index:
insert a new importing parameter index type i in your action method.( you will automatically get it)
now get the ref. of your ui element->table here.
how to get the ref to table ui element:
DATA lr_table_ui_element type ref to cl_wd_table
lr_table_ui_element ?= view->get_element( 'ENTER_YOUR_TABLE_ID').
check the index with the table or try using one of the method from class cl_wd_table.
Now you need to change the property of this row from textview to inputfiled dynamically I am not sure how but I will try and let you know.
Thanks & Regards,
Abhinav
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.