cancel
Showing results for 
Search instead for 
Did you mean: 

Deleting a selected row in a table control

Former Member
0 Kudos

Hi,

There is one table control in my WDA application.

If the user selects one row and click the delete row button ,

the row should be deleted from the table control.Give me some sample code to do this.

Regards,

Charumathi.B

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Charumathi ,

inside the action of your delete button using

code wizard read the node thats binded to the tablectrl into a work area wa_tabll (just read the lead selected one) .. now.

using the code wizard read the whole itab from that node to itab.

now delete wa_tabll from itab.

then bind the itab back to node.. thats all

Regards

Sarath

Former Member
0 Kudos

Hi Sarath/Alex,

How to read the lead selected node ?

Regards,

Charumathi.B

Former Member
0 Kudos

hi Charumathi ,

just use the code wizard -> read node-> choose your required node.. its returning the lead selected record.

Regards

Sarath

Former Member
0 Kudos

hi charumathi.......

you can also make use of the class cl_wd_table and the method get_on_lead_select.

---regards,

alex b justin

Former Member
0 Kudos

Hi Sarath/ Alex ,

Thanks .It is working now.

Regards,

Charumathi.B

Answers (4)

Answers (4)

Former Member
0 Kudos

Sample code:

DATA lo_nd_node_details TYPE REF TO if_wd_context_node.

DATA lo_el_node_details TYPE REF TO if_wd_context_element.

DATA ls_node_details TYPE wd_this->element_node_details.

DATA check TYPE abap_bool.

lo_nd_node_details = wd_context->get_child_node( name = wd_this->wdctx_node_details ).

lo_el_node_details = lo_nd_node_details->get_lead_selection( ).

check = lo_nd_node_details->remove_element( lo_el_node_details ).

Regards,

Rakesh.

Former Member
0 Kudos

get the selected row .

in the delete action code

get all the table rows in a internal table and delete the selected row using your own logic.

again bind the internal table with the UI element.

i think this will work.

Former Member
0 Kudos

hi charumathi....

you can get the selected row by lead selection.

read the node.

consider the record to be deleted is in index 5 and you are having 6 records in it.

then:

delete itab index 5.

now bind it again to the node.

--regards,

alex b justin

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

write this code in the event handler method of the table onSelect Event.

data: lr_node type ref to if_wd_context_node.

data: lr_element type ref to if_wd_Context_element.

lr_node = wd_context->get_child_node( '<node_name>' ).

  • this statement will return the selected row element

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

lr_node->remove_element( element = lr_element ).

Abhi