on 05-06-2008 7:39 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.