cancel
Showing results for 
Search instead for 
Did you mean: 

How to select all rows of a table in a view?

Former Member
0 Kudos

Hi All,

In the web dynpro abap component, there is a view containing a table UI element and this table UI element contains four table columns and one master column(treebykeytablecolumn) which I am not familiar with, so can anyone tell me how to select all rows without manually expand the whole tree structure?

Thanks in advance!

BR, Dawson

Accepted Solutions (0)

Answers (1)

Answers (1)

ChrisPaine
Active Contributor
0 Kudos

Hello,

Firstly - you'll have to ensure that the node you've bound into the tree allow for multi selection.

Then - you'll need to write some code to iterate down the structure and select everything, fortunately I had one such example just at hand.

Create a method with one input parameter of node type ref to if_wd_context_node.

I'm assuming you have a recursive node with a subnode call "SUB_NODE".

Call this method passing in the top level node:

data: lo_nd type ref to if_wd_context_node.
  lo_nd = wd_context->get_child_node( name = wd_this->wdctx_root_node ).
  select_all( lo_nd ).

method select_all .

  data: lo_subnode type ref to if_wd_context_node,
        lt_elements type wdr_context_element_set,
        lo_element type ref to if_wd_context_element.

* remove lead selection
  node->set_lead_selection_index( if_wd_context_node=>no_selection ).
 
* get any sub nodes

  lt_elements = node->get_elements( ).

  loop at lt_elements into lo_element.
    lo_element->set_selected( abap_true ).
    lo_subnode = lo_element->get_child_node( 'SUB_NODE' ).
    select_all( lo_subnode ).
  endloop.

endmethod.

Good luck.

Chris

Former Member
0 Kudos

Hi Chris,

there is no child node for the root node in the view context, and the node structure is as following;

Mynode(type is node)

attribute1_id(type is attribute)

attribute2_id_parent(type is attribute, and it is the parent of attribute1_id)

and there is no recursion node here, could you please give me another suggestion to solve this problem?

Thanks.

BR, Dawson