Skip to Content
0

set relation in cl_simple_tree_model for existing node

Feb 07 at 09:16 AM

104

avatar image

Hi there!

I am struggeling with inserting a node at a specific position using the cl_simple_tree_model.

I build up a tree structure. No big deal.

Let's say I display customer orders and the order items as child nodes.

Then the user changes the customer order and changes, adds or deletes items. I don't want to make fuzz about every single item and check if it's still there, has been deleted or added or if the text has changed or status has changed and so on.

My idea was to simply delete the node of the customer order and rebuild it completely. That's also possible and I can add the new nodes using method ADD_NODES and ADD_ITEMS.

BUT: I can only add the nodes using the relationships

  • First/ Next/ Last child
  • First/ Next/ Last sibling

So an order "in the middle" will be placed at the top (first child) or bottom (last child) of the structure.

How can I place the "updated" node at exactly the same position as before?

thanks for any idea!

Enno

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Enno Wulff Feb 09 at 02:56 PM
0

It's so easy... *head->table*

Method ADD_NODE and ADD_NODES have the importing parameter "RELATIVE_NODE_KEY".

If you want to "Update" the current node you just have to add the updated nodes with RELATIVE_NODE_KEY = new_node_key and RELATIONSHIP = next_sibling or prev_sibling. Then you delete the old node.

If you have unique node-keys, like order number, or material number, then you first have to check NODE_GET_PREV_SIBLING, then delete the old node and afterwards add the new nodes with RELATIVE_NODE_KEY = prev_sibling_of_old_node and RELATIONSHIP = next_sibling.

If there is no previous sibling, then you have to find out the parent NODE_GET_PARENT and set relationship to first_child.

Share
10 |10000 characters needed characters left characters exceeded
Domi Bigl Feb 08 at 05:43 PM
1

Hi

I always rebuild the tree completely on any change, so I only have to deal with inserts, updates, deletes, sortorder, ... in my ITab(s) and dont really care about this in Tree build methods.

And since the tree is UI (mostly with user interaction) I try to keep it short and readable and therefore had nevere any performance issues regarding tree rebuild or GUI transfer!

If anyone has a better (delta) solution - I would use it!

kr

Domi

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks Domi! I would like to avoid a complete rebuild as we have thousands of nodes in the view... :(

I will try to just update the "order node", delete all child nodes and add only the child nodes.

0

Hi

Yea, I do understand - that's why I try to keep the tree "short and readable"

User only need 5, 10 maybe 20 orders on one screen, so you could add some filter or search criteria?

I often use a hyperlink in the 1st root item to add an filter via a popup.

regards

Domi

1