Hi,
I have a tree view with a list of nodes which have checkboxes. Once a user checks some of the nodes I persist this information to the database. I then want to load this info back onto the page. I cannot seem to get this working.
I'm doing something like:
$("#treeview").kendoTreeView({
checkboxes: {
template: "<input type='checkbox' #= CheckItem(item.IsSet) # />"
},
dataSource: inline,
dataTextField: ["ComponentActionName"],
loadOnDemand: false
});
function CheckItem(IsSet) {
if (IsSet) {
return "checked='checked'";
}
else {
return "";
}
}
This actually works fine, in that the UI shows the correct nodes checked. The problem is that when I try to save this data again with a function like:
function checkedNodeIds(nodes, checkedNodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].checked) {
checkedNodes.push(nodes[i].ComponentActionName);
}
if (nodes[i].hasChildren) {
checkedNodeIds(nodes[i].children.view(), checkedNodes);
}
}
}
nodes[i].checked shows as undefined for the nodes unless I manually unselect and reselect them. Is there a property similar to the dataTextField where I can specify the field on the data which indicates if the node should be checked or any other way of achieving this?
Thanks,
Keith
I have a tree view with a list of nodes which have checkboxes. Once a user checks some of the nodes I persist this information to the database. I then want to load this info back onto the page. I cannot seem to get this working.
I'm doing something like:
$("#treeview").kendoTreeView({
checkboxes: {
template: "<input type='checkbox' #= CheckItem(item.IsSet) # />"
},
dataSource: inline,
dataTextField: ["ComponentActionName"],
loadOnDemand: false
});
function CheckItem(IsSet) {
if (IsSet) {
return "checked='checked'";
}
else {
return "";
}
}
This actually works fine, in that the UI shows the correct nodes checked. The problem is that when I try to save this data again with a function like:
function checkedNodeIds(nodes, checkedNodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].checked) {
checkedNodes.push(nodes[i].ComponentActionName);
}
if (nodes[i].hasChildren) {
checkedNodeIds(nodes[i].children.view(), checkedNodes);
}
}
}
nodes[i].checked shows as undefined for the nodes unless I manually unselect and reselect them. Is there a property similar to the dataTextField where I can specify the field on the data which indicates if the node should be checked or any other way of achieving this?
Thanks,
Keith