Using checkboxes to select nodes in TreeView
In TreeView, each node can have a checkbox associated with it. By using a checkbox, you can select multiple nodes in the tree and perform an action.
How to do it…
To add a checkbox next to a node in TreeView, specify the checkboxes
attribute as true
when initializing the TreeView widget:
$('#treeView').kendoTreeView({ checkboxes: true });
If you want the child nodes to be selected when the parent node is selected, then specify checkChildren
as true
:
$('#treeView').kendoTreeView({ checkboxes: { checkChildren: true } });
Now, when you select the parent node, all child nodes within the parent node would be selected. It is also possible to specify nodes as checked when they are rendered. In the DataSource
configuration, specify checked
as true
:
$('#treeView').kendoTreeView({ checkboxes: { checkChildren: true }, dataSource: [{ text: "Directory1", items: [ {text: "File1.txt"}, {text: "File2.txt"}...