var treeView = $("#treeview").data("kendoTreeView");
var nodes = treeView.dataSource.view();
initSetChecked(ids,nodes);
initSetChecked(ids,nodes);
function initSetChecked(ids,nodes){
if(ids != null && ids != ""){
for (var i = 0; i < ids.length; i++) {
for (var j = 0; j < nodes.length; j++) {
if (ids[i] == nodes[j].id) {
nodes[j].set("checked",true);//设置选中复选框
treeView.expand(treeView.findByUid(nodes[j].uid));//设置展开节点
continue ;
}else{
if (nodes[j].hasChildren) {
initSetChecked(ids,nodes[j].children.view());
}
}
}
}
}
}
转载于:https://my.oschina.net/u/2489390/blog/658218