This is a migrated thread and some comments may be shown as answers.

Delete with subnode pullup

3 Answers 58 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David Gauthier
Top achievements
Rank 1
David Gauthier asked on 19 Oct 2010, 08:59 PM
Hi,

When using a treeview control that is populating via a web service how can I delete a node (from client side) and pull all of its children up (if any) and make them children of the deleted node's parent? I only want to delete the single node, not the entire subtree.

Example A->B->C, if I delete B I want C to move up under A.

Also if the node that I am deleting has not been expanded, then it should be expanded first so that the children that get pulled up are not only the currently displayed children but all logical children from the web service population as well.

Thanks

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 20 Oct 2010, 08:40 AM
Hi David,


Make use of client side api of the treeview to delete/add nodes.
You can find the demo here: TreeView / Add/Remove/Disable Nodes

Make changes for getting the child nodes (if any) and add to the parent node before deleting.


-Shinu.
0
David Gauthier
Top achievements
Rank 1
answered on 20 Oct 2010, 02:15 PM
Sorry but that example does not cover the use case I've described since the nodes are being added manually the user as opposed to a web service and it deletes the entire subtree under the node being deleted. Specifically the use case is deleting a single node in the tree which is set to be expanded by a web service but has not yet been expanded. The problem I'm having is with deleting such a node or pulling up a child node that has unexpanded children.

Thanks
0
Accepted
Nikolay Tsenkov
Telerik team
answered on 22 Oct 2010, 11:54 AM
Hi David Gauthier,

You can persist the action in 2 variables - deletion (boolean) and nodeToDelete (RadTreeNode).

In the handler of the delete action (I would guess that this is the ClientContextMenuItemClicked handler) you check if the node is expanded. If it is - then it's pretty simple:
A. you get the child nodes (node.get_allNodes()) add them to it's parent and delete the node.
If the node is not expanded, then persist the action as stated above, expand the node (node.set_expanded(true)) and on ClientNodePopulated you check if "deletion" is true, if yes then perform A. on nodeToDelete and set the flag (deletion) back to false.

I hope the procedure was clear enough and you will not experience any hard time implementing it!


Regards,
Nikolay Tsenkov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeView
Asked by
David Gauthier
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
David Gauthier
Top achievements
Rank 1
Nikolay Tsenkov
Telerik team
Share this question
or