cancel
Showing results for 
Search instead for 
Did you mean: 

Collapse All and Expand All functionality in Tree

Former Member
0 Kudos

Hi All,

I am using TreeByNestingTableColumn element to display the tree hierarchy .

Does anyone knows how to implement Collapse All and Expand All functionality for this tree (if someone have sample code for these functionality then it will be great for me) ?

Thanks in advance.

Ravi.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Thanks for your reply ,

I am using the following node structure for displaying my hierarchy.

Hierarchy -


> node .

|

RecursiveHierarchy -


> recursive node .

lets suppose using this I have following tree.

Root -


> it is stored in <Hierachy> node

|

Child1 -


> it is stored in <Hierachy1.RecursiveHierarchy1>

Child2 -


>it is stored in <Hierachy1.RecursiveHierarchy2>

|

Grandchild2----


>it is stored in<Hierachy1.RecursiveHierarchy2.RecursiveHierarchy1>

Now for this example your code wont work .... so please do you have any idea how can I apply code to this sort of tree ?

Regards,

Ravi

Former Member
0 Kudos

Hello Ravindra Sahu,

Code for EXPAND ALL button:

*step 1:Access node

lo_nd_tree_hierarchy = wd_context->get_child_node( name = wd_this->wdctx_tree_hierarchy ).

*step2: Extract all the table entries from node which is binded to table

lo_nd_tree_hierarchy->get_static_attributes_table(

IMPORTING

table = lt_tree_hierarchy ).

*step3:set element attribute Expanded to abap_true

loop at lt_tree_hierarchy ASSIGNING <ls_tree_hierarchy>.

<ls_tree_hierarchy>-expanded = abap_true.

endloop.

*step4: Finally the updated data needs to be binded.

lo_nd_tree_hierarchy->bind_table( lt_tree_hierarchy ).

Code for COLLAPSE ALL button:

*step 1:Access node

lo_nd_tree_hierarchy = wd_context->get_child_node( name = wd_this->wdctx_tree_hierarchy ).

*step2: Extract all the table entries from node which is binded to table

lo_nd_tree_hierarchy->get_static_attributes_table(

IMPORTING

table = lt_tree_hierarchy ).

*step3:set element attribute Expanded to abap_true

loop at lt_tree_hierarchy ASSIGNING <ls_tree_hierarchy>.

<ls_tree_hierarchy>-expanded = abap_false.

endloop.

*step4: Finally the updated data needs to be binded.

lo_nd_tree_hierarchy->bind_table( lt_tree_hierarchy ).

Please don't forget giving REWARD points...:-)

Edited by: Bharath Komarapalem on Jul 11, 2008 9:17 AM