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

TreeView checkboxes; checkChildren

1 Answer 158 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Mathias
Top achievements
Rank 1
Mathias asked on 20 Jan 2015, 10:34 AM
Hey i've a Problem with KendoTreeview. I build a TreeView with a json Datasource
[
{"id":1,"text":"foo","expanded":true,"items":
[
{"id":2,"text":"foo2","expanded":false,"checked":false},
{"id":3,"text":"foo2-1","expanded":false,"items":
[
{"id":4,"text":"foo3","expanded":false,"checked":false}
]
,"checked":false}
],"checked":true
}
]
JS Code:
$(document).ready(function() {
var dataSource = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: servlet,
datatype: "json",
contentType: "application/json"
}

},
schema: {
model: {
children: "items",
id: "id"
},
data: function(data) {
var dataArray = eval(data);
return dataArray;
}
}
});

var treeView = $("#treeView").kendoTreeView({

dataSource: dataSource,
dataTextField: "text",
checkboxes: {
checkChildren: true
}
});
It works well but if i use checkChildren: true the pre check is not working. if i use only checkboxes: true without checkchildren pre check works but not check all childs. What is wrong ?

1 Answer, 1 is accepted

Sort by
0
Alex Gyoshev
Telerik team
answered on 22 Jan 2015, 08:17 AM

Hello Mathias,

The nodes, serialized in such way, conflict with the checkChildren functionality -- if the root node is checked, all its child nodes need to be checked, too. You can either serialize all nodes as checked, or not serialize the checked state for the child nodes (as seen in this Dojo snippet).

Regards,
Alex Gyoshev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
TreeView
Asked by
Mathias
Top achievements
Rank 1
Answers by
Alex Gyoshev
Telerik team
Share this question
or