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. Image for the cookie policy date

Copying ejTreeView exact contents to secodn ejTreeView

I am using an ejTreeView in my ASP.NET project.
I have 1 tree view that the user uses on one page, and then I want to display a second tree view with all the same data on the following page as a confirmation of what they had chosen on the 1st treeview.

How can I easily copy / duplicate my treeview with all its content and selections to a second treeview?

1 Reply

PR Piramanayagam Ramakrishnan Syncfusion Team January 18, 2017 12:20 PM UTC

Hi Marc, 
 
Thanks for contacting Syncfusion support. 
 
We have analyzed your query. We can achieve your requirement (“How can I easily copy / duplicate my treeview with all its content and selections to a second treeview”) in TreeView control by using getTreeData public method.  
 
This method is used to get updated data source after performing some operation such as drag and drop, node editing, adding and removing node from client side in TreeView. It will return the updated data source as JSON array object. Please refer the below code sample, 
 
[Script] 
 
var treeobj = $("#<%=Treeview.ClientID%>").data("ejTreeView"); 
var dataSource = treeobj.getTreeData(); 
var treedata = JSON.stringify({ sessionval: dataSource }); 
 
 
We can save this data source into session. We can retain this data source from session in another page and assign this data source to another TreeView. 
  
For more details on the getTreeData method, please refer to the help document link:
http://help.syncfusion.com/js/api/ejtreeview#methods:gettreedata 
 
For your reference, we have prepared a sample based on this, and it can be downloaded from the following location: Sample 
 
Please let us know whether the provided sample is helpful in achieving your requirement. If not, get back to us with more information to proceed further. 
 
Regards, 
Piramanayagam R

Loader.
Up arrow icon