I'm using kendo mvvm frameworks. I would like to check certain checkbox with an array contain the checkbox value. Example
var checkboxValue=["a","c"]
[x]a
[ ]b
[x]c
Try this:
var values = ["A", "C"];
var setTreeViewValues = function(values) {
var tv = $("#treeview").data("kendoTreeView");
tv.dataItems().forEach(function(dataItem) {
if (values.indexOf(dataItem.text) > -1) {
dataItem.set("checked", true);
}
});
};
setTreeViewValues(values);
It will check the node if the array contains its text. You better call this method on dataBound
event if your treeView get its data from an async request.