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

Bind Checkboxes to DataSource field in the TreeView

6 Answers 302 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Salim
Top achievements
Rank 1
Salim asked on 31 Oct 2016, 01:43 PM
Is there a way to bind the checkboxes of the TreeView to a field in the DataSource?

6 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 01 Nov 2016, 01:31 PM
Hello Salim,

The checkboxes can be bound to the HierarchicalDataSource with the checked field(please have in mind that the field name is important).

I made a Dojo example demonstrating how based on a field from the HierarchicalDataSource, the TreeView nodes will be checked or not:

http://dojo.telerik.com/usOPu

I hope this is helpful.

Regards,
Stefan
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
0
Salim
Top achievements
Rank 1
answered on 01 Nov 2016, 02:16 PM

Thanks Stefan.

1. It doesn't work when loadOnDemand is set to "true"

2. Can we bind it to our own field other than the "checked"?

0
Stefan
Telerik team
answered on 02 Nov 2016, 01:27 PM
Hello Salim,

Regarding the questions:

1) It doesn't work when loadOnDemand is set to "true"- The provided example is working as expected when the loadOnDemand property is set to true. An issue can occur when the loadOnDemand is set to true and the nested levels are more than three because the DataSource is not read in a single pass when provided to the TreeView. This causes the TreeView to load only the first level, infer that all nodes are not checked, and then propagate the checked state downwards, as in remote loading scenarios.

http://dojo.telerik.com/Ebovu

2) Can we bind it to our own field other than the "checked"? - When the checked is used, the widget will automatically bind its value to the checkboxes, if other fields are used then all of the bindings have to be done manually as this scenario is not officially supported.

Regards,
Stefan
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
0
Salim
Top achievements
Rank 1
answered on 02 Nov 2016, 02:53 PM
What you are saying about the loadOnDemand is true if we do not load all the data once. We have all the data, but we don't want to render them on the UI because the data is huge. That's why we are using loadOnDemand. The TreeView should check the data and not the UI in order to determine the state of the UI
0
Salim
Top achievements
Rank 1
answered on 02 Nov 2016, 02:54 PM

Sorry, I meant in the latest sentence:

. The TreeView should check the data and not the UI in order to determine the state of the checkbox of the parent node

0
Stefan
Telerik team
answered on 04 Nov 2016, 02:38 PM
Hello Salim,

The reason for this is because the loadOnDemand is designed to work with data which is loaded from the server to make smaller requests. And when only a part of the data is fetched the widget does not have an information for the child node as they are not loaded yet.

When a local data is used there is no need of the loadOnDemand property as it will not affect the application because the data is already available, using it can only lead to the described issue.

Also, if the data is available the loadOnDemand will not affect the rendering as the data will be collapsed by default.

Regards,
Stefan
Telerik by Progress
 
Build rich, delightful, *native* Angular 2 apps with Kendo UI for Angular 2. Try it out today! Kendo UI for Angular 2 (currently in beta) is a jQuery-free toolset, written in TypeScript, designed from the ground up to offer true, native Angular 2 components.
 
Tags
TreeView
Asked by
Salim
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Salim
Top achievements
Rank 1
Share this question
or