2007 Apr 04 4:18 AM
Hello,
is there a possibility to initialize the node_keys of a cl_gui_alv_tree? After I have delteted all nodes using method delete_all_nodes to refresh display on gui I want to set the expanded nodes. But unfortunately when I add the nodes again after having used delete_all_nodes.... the old indexes are still occupied and for the new added nodes the node_keys beginn a the end of the old indexes. But I want the new added nodes to have exactely the same as before (so starting with 1 and so on).
Could anyone of you please help me?
Kind regards
Tobias
Hello,
is there a possibility to initialize the node_keys of a cl_gui_alv_tree? After I have delteted all nodes using method delete_all_nodes to refresh display on gui I want to set the expanded nodes. But unfortunately when I add the nodes again after having used delete_all_nodes.... the old indexes are still occupied and for the new added nodes the node_keys beginn a the end of the old indexes. But I want the new added nodes to have exactely the same as before (so starting with 1 and so on).
Could anyone of you please help me?
Kind regards
Tobias
2007 Apr 04 8:35 AM
Hello Tobias ,
If I understood your problem correct, you need to set the hierarchy again to display in the order you want and i think you have to use
CALL METHOD cl_gui_cfw=>flush after using delete_all_nodes.
After you set the hierarchy make sure that you did the frontend update.
and may be this could give some idea
<a href="http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_refresh.htm">http://www.sapdevelopment.co.uk/reporting/alv/alvtree/alvtree_refresh.htm</a>
Hope this helps,
Caglar
2007 Apr 04 9:21 AM
Hi A. Caglar Ozkor,
thanks for your answer but it is not exactly what i want to achieve, because after having refreshed the tree (which works) the items node numbers have changend. After each refreshing the key_node numbers increase.
Example:
tree with 300 nodes:
node_key of first node 1
after first refresh
node_key of first node 301
after seconde refresh
node_key of first node 601
i want the node_keys of node 1 to stay at 1 no matter how i often i refresh...
Do you understand? Thanks so much for your help!
Tobias
2007 Apr 04 10:57 AM
Hello Tobias,
I found that CL_ALV_TREE_BASE has a method (ADD_MODEL_NODE ) which is used by CL_GUI_ALV_TREE in method ADD_NODE and in this method there is a private attribute 'M_NODE_KEY_COUNT' which increments the next related key number by one. And it is set as 1 when creating the tree object.
Kind Regards,
Caglar
2007 Apr 04 11:04 AM
thanks very much for your research.. i guess then i can't do anything as delete and create the "same" alv object with every refresh.... bad but right now the only possible solution to me...
2007 Apr 04 11:09 AM
hi tobias ,
I didn' t want to suggest you that but I didn' t find another solution except
re-creating it.
Kind regards,
Caglar
2007 Apr 17 2:14 PM
Hi Tobias ,
I had the same problem , actually in class cl_alv_base_tree attribute M_NODE_KEY_COUNT is private and so we cant access it.
there is no way other than creating the tree object again to intialize the counter.
ya the other option is u can keep the track of the last parent node by
CALL METHOD gref_tree_default->add_node
EXPORTING
i_relat_node_key = lv_root_key
i_relationship = cl_gui_column_tree=>relat_last_child
is_outtab_line = ls_default
i_node_text = lv_node_text
it_item_layout = lt_layout_item "JK
is_node_layout = lv_layout_node
IMPORTING
e_new_node_key = gv_last_parent_default.
so using gv_last_parent_defaultu can get the last parent node.
next time when u access tree nodes refer this global variable gv_last_parent_default to start with.
I dont know what;s your functionality is but I wanted to disable all tree nodes so i started from last parent node and using get_prev_sibling i got previous parent node .
i think storing last parent node and refering it for the next time solves the problem .
Hope it works for u also.