on 10-14-2008 4:46 PM
Hello guys,
ich have a Problem deleting Lines from a table UI Element.
The Situation is like this:
I have a table ui element. if i click on a line and then on a button
i want to delete the line from the table.
How can i do this ?
Thanks a lot.
René
Hi Rene,
I am assuming here that the Table UI would be bound to a context node mapped to a structure. The table UI would display the rows as pouplated against the context node ( implying node cardinality would be 0:n or 1:n and thus would <<node>> ->get_static_attributes would yeild an internal table ).
There are two approaches towards tackling this:
1) If the intent is to delete the line from the table UI and subsequently delete it from a table in the underlying database, then you could do the following:
When you select a line from the table UI and click on the delete button, get the lead selection element and issue a delete of the row in the Database. Subsequently read the table rows from the DB and bind the internal table to the node mapped to the tabel UI. (This action would be actually refreshing the UI with real time DB value once the delete is clicked. Thus the new set of records does not have the deleted row) . This is performance intensive and is generally used if there is a need for the most recent data to be displayed on each event)
2) If the intent is just to remove the line from the table UI, then on click of delete, just delete the lead selected elements from the context node mapped to the Table UI
DATA: lo_node TYPE REF TO if_wd_context_node,
lo_ele TYPE REF TO if_wd_context_element.
lo_node = wd_context->get_child_node( name = wd_this-><<table_ui_node>> ).
CALL METHOD lo_node->get_lead_selection
RECEIVING
element = lo_ele.
CALL METHOD lo_node->remove_element
EXPORTING
element = lo_ele
receiving
has_been_removed = fg_has_been_removed.
Hope this was clear.
Thanks,
Rashmi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Rene,
To select multiple rows from thetable you have to change selection to 0..n of the context node which is attached to table.
To get the selected rows write the below logic.
data:node_flights type ref to if_wd_context_node,
it_selected type WDR_CONTEXT_ELEMENT_SET,
wa_selected type ref to if_wd_context_elemnt.
node_flights = wd_context->get_childnode( 'FLIGHTS' ).
it_selected = node_flights->get_selected_elements( ).
loop at it_selected into wa_selected.
node_flights->remove_element
exporting
elelment = wa_selected.
endloop.
Hi Rene,
Using "LeadSelection" you can select only 1 row at a time. You will have to make use of "Selection" for achieving this. First you will have to change the selection mode of the table to multiple & also change the selection property for the related context to 0..n . Use the below coding to get the multiple rows selected by the user into an internal table . You can then loop through this new internal table and delete those corresponding records from the main internal table. Hope that this helps resolve your problem.
Regards,
Uday
METHOD onactioncopy_selected_rows .
DATA: wd_node TYPE REF TO if_wd_context_node,
wa_temp TYPE REF TO if_wd_context_element,
lt_temp TYPE wdr_context_element_set.
wd_node = wd_context->get_child_node( name = 'NODE1' ).
CALL METHOD wd_node->get_selected_elements
RECEIVING
set = lt_temp.
LOOP AT lt_temp INTO wa_temp.
wd_node->remove_element( exporting element = wa_temp ).
ENDLOOP.
User | Count |
---|---|
84 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
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.