cancel
Showing results for 
Search instead for 
Did you mean: 

How to select all/deselect all records in a Table UI

Former Member
0 Kudos

How do I select all/deselect all records in a Table UI? Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

aaron_morden2
Contributor
0 Kudos

Create two buttons: Select All & Unselect

Use the following example code in the actions assigned to each button.


  DATA lo_nd_table TYPE REF TO if_wd_context_node.
  lo_nd_table = wd_context->get_child_node( name = wd_this->wdctx_table ).
  
  DATA int TYPE i VALUE 1.
  DATA count TYPE i.

  count = lo_nd_table->get_element_count( ).
  
  DO count TIMES.
    lo_nd_table->set_selected(
      flag   = abap_true
      index  = int ).
    ADD 1 TO int.
  ENDDO.

For the deselect, just change the flag to abap_false.

Make sure your context properties are set with Selection 0...n and Uncheck Initialization Lead Selection.

Former Member
0 Kudos

Thanks! It works now.

aaron_morden2
Contributor
0 Kudos

FYI...

I just noticed that when you change the Selection property on the context node to 0...n or 1...n, it will automatically put an icon in the upper left corner of the table that will allow you to Select All/Deselect All. No need to write any code at all.

Answers (0)