We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I Undo/Redo the move or delete action in TreeView?

Description

TreeView with enabled drag and drop allows you to move the nodes anywhere within the TreeView. To prevent the unintentional moving or removing nodes, you can Undo/Redo them.

Solution

The following scenario undoes the deleted or moved node from TreeView using a button click event.

  1. Create a TreeView with enabled drag and drop. TreeView node deletion is implemented using ContextMenu, under ClientSideOnClick event. Delete the TreeView node using removeNode() API in the client script and store the node value and its parent ID to retrieve it back to same position on undo. Similarly store the value of node and its parent id under ClientSideOnNodeDragStarted() event. Refer the following sample link to create Treeview with context menu.

 

Sample link: http://asp.syncfusion.com/demos/web/TreeView/ContextMenu.aspx

 

  1. Define a Button for performing undo action and restore the nodes back to its position using appendChild() to the TreeView object, based on its parent ID. Now right-click on TreeView node and delete it or drag the nodes within the TreeView. Click on the undo button that restores the previous actions accordingly. Refer the following code example.

HTML

 

Article ID: Published Date: Last Revised Date: Platform: Control:
2579 09/03/2014 12/15/2014 ASP.NET Web Forms TreeView
Tags:
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon