In the code below, unable to set the checkbox to checked. I would like to set certain checkbox checked=true. is there any way to solve the problem in kendo-mvvm where the databind will be done in the html part?
expected output is
[ ]General
[X]Name
[ ]Device
[X]Status
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled</title>
<link rel="stylesheet" href="http://ift.tt/2dZXwz7">
<link rel="stylesheet" href="http://ift.tt/2dm6XLu">
<link rel="stylesheet" href="http://ift.tt/2dZXaID">
<link rel="stylesheet" href="http://ift.tt/2dm62e4">
<script src="http://ift.tt/2c6Phn9"></script>
<script src="http://ift.tt/2dm7Pj0"></script>
<script src="http://ift.tt/2dZWBPm"></script>
<script src="http://ift.tt/2dyGzxD"></script>
<script>
$(function() {
$("#treeview").kendoTreeView({
dataSource: {
data: [{
id: 7,
parent_id: 0,
text: "Work Order assignment",
value: "Work Order assignment",
expanded: true,
items: [
{ id: 71, parent_id: 7, text: "Name", value: "woName" },
{ id: 72, parent_id: 7, text: "Device", value: "woDevice" },
{ id: 73, parent_id: 7, text: "Status", value: "woStatus" }]
}]
},
checkboxes: true
});
var values = ["woName","woStatus"];
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);
});
</script>
</head>
<body>
<div id="treeview"></div>
</body>
</html>
Aucun commentaire:
Enregistrer un commentaire