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

How to copy checked nodes from one treeview to another treeview?

1 Answer 99 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Ashik
Top achievements
Rank 1
Ashik asked on 19 Dec 2016, 07:52 AM

I have a treeview with three hierarchy which has checkboxes along with them. I need to move only those data for which checkbox is checked to another treeview.

refer the dojo here; 

http://dojo.telerik.com/eGINo/2

Can anybody let me know any idea to achieve this? 

1 Answer, 1 is accepted

Sort by
0
Ivan Zhekov
Telerik team
answered on 20 Dec 2016, 08:31 AM
While it's easy to iterate over a treeview and get the checked children, reconstructing the treeview might be challenging:

Kendo TreeView does not keep active track of checked items. Instead, they are pushed as a flat list to the server whenever you perform post request.

Iterating over the treeview is actually quite easy and we have an excellent blog post about it -- http://www.telerik.com/blogs/how-to-get-the-checked-items-from-a-treeview-with-checkboxes.

Still, we are ending up with a flat list.

If we want to actually build a treeview i.e. a nested structure, how do we guarantee that we have it? And I will elaborate.

What if I select the inner most node (say item with index 1.5.6.10). What should be copied over? Just the node?

Then I select it's parent  (1.5.6). When the treeview is updated do we show the parent / child relation?

Then I select a new end node (1.2.1.11). How do we show that? do we show it at the same level as 1.5.6? Because if we do, it will not be an accurate representation.

If we are to complicate the "show checkbox" logic, say dont show it on the top level and on the 3 and then 5th and so on and so forth, how do we construct the tree then?

To sum up, showing the checked items is quite easy -- just iterate over the datasource, as shown in the article I've sent you. Displaying them in a nested fashion is hard or next to impossible due to various customization options.

Regards,
Ivan Zhekov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
TreeView
Asked by
Ashik
Top achievements
Rank 1
Answers by
Ivan Zhekov
Telerik team
Share this question
or