cancel
Showing results for 
Search instead for 
Did you mean: 

Web Dynpro Tree expanding

Former Member
0 Kudos

Hi there!

I am using the tree element in web dynpro.

Not the tree in the table.

I need to expand a part of the tree during loading

I do not find an example.

Any help is warmly appreciated.

Thanks in advance, Frank

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

When you add the tree node, you can set the 'Expanded' property to true if you want it expanded during loading. This will work if you know during design time itself which nodes are to be expanded.

If this is determined only at runtime, then you can bind the expanded property of the node to a context attribute and set it accordingly.

Regards,

Nithya

Former Member
0 Kudos

Yes

it try it

When i have a tree with on level it isnt't a problem.

But i have a treewith several levels

Can you help me with a example

thanks Frank

Former Member
0 Kudos

Hi,

the "dynamic" tree expansion depends on who you populate the tree content e.g. how you load the data to your tree.

In my application, I have choosen to load the root nodes, first - all over sub-nodes (including items) are loaded "on demand" that means the user clicks on the node. This click will trigger the the action onLoadChildren which pulls the data from a data provider and binds the retrieved data to the corresponding

context node.

This expansion can be perfomed automatically by a recursive method which is called when a user pushes a button called "Expand all"....

I don't have much time to explain the details, but I will provided the source code..., hope it helps!

Darko

-


Source Code -


Import to the Method:

i_node_ref type IF_WD_CONTEXT_NODE = Reference to the context node

METHOD nav_tree_expand_all.

  • Data declaration

----


DATA node_elements TYPE wdr_context_element_set.

DATA node_element LIKE LINE OF node_elements.

DATA child_node TYPE REF TO if_wd_context_node.

DATA ls_tree_attr TYPE zlm_str_tree_gen.

DATA lt_tree TYPE zlm_tty_tree_gen.

  • Get all node elements

----


node_elements = i_node_ref->get_elements( ).

  • Loop over each element

----


LOOP AT node_elements INTO node_element.

" Get Static attributes

node_element->get_static_attributes( IMPORTING static_attributes = ls_tree_attr ).

" Check if data has already been loaded

IF ls_tree_attr-children_loaded = abap_true.

" now we know that the data has been loaded, only the elements have to be declared as expanded

ls_tree_attr-is_expanded = abap_true.

node_element->set_static_attributes( EXPORTING static_attributes = ls_tree_attr ).

" get possible other nodes recursively

child_node = node_element->get_child_node( 'SUBTREE' ).

me->nav_tree_expand_all( EXPORTING i_node_ref = child_node

i_screen_id = i_screen_id

i_component_id = i_component_id ).

ELSE.

" data has not been loaded yet...

" First load the nodes...

clear lt_tree.

me->get_nav_tree_nodes( .....importing lt_tree.). Custom specific data retrieval

IF lt_tree IS NOT INITIAL.

child_node = node_element->get_child_node( 'SUBTREE' ).

child_node->bind_table( lt_tree ).

" Update Attributes of the node

ls_tree_attr-is_expanded = abap_true.

ls_tree_attr-children_loaded = abap_true.

node_element->set_static_attributes( EXPORTING static_attributes = ls_tree_attr ).

" Call the method again recursively...

me->nav_tree_expand_all( EXPORTING i_node_ref = child_node

i_screen_id = i_screen_id

i_component_id = i_component_id ).

ENDIF.

" ... then load the items

CLEAR lt_tree.

me->get_nav_tree_items( .....importing lt_tree.). Custom specific data retrieval

IF lt_tree IS NOT INITIAL.

" Update Attributes of the node

ls_tree_attr-is_expanded = abap_true.

ls_tree_attr-children_loaded = abap_true.

node_element->set_static_attributes( EXPORTING static_attributes = ls_tree_attr ).

child_node = node_element->get_child_node( 'ITEM' ).

child_node->bind_table( lt_tree ).

ENDIF.

ENDIF.

ENDLOOP.

RETURN.

Edited by: Darko Mocelj on May 7, 2008 8:57 PM