Delete with subnode pullup

4 posts, 1 answers
  1. David Gauthier
    David Gauthier avatar
    2 posts
    Member since:
    Mar 2010

    Posted 19 Oct 2010 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Oct 2010 Link to this post

    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.
  3. David Gauthier
    David Gauthier avatar
    2 posts
    Member since:
    Mar 2010

    Posted 20 Oct 2010 Link to this post

    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
  4. Answer
    Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 22 Oct 2010 Link to this post

    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
Back to Top