//treeview
var serviceRoot = "../../../HumanResource/EmployeeManagement/Designation/getTemplate.php";
homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: serviceRoot,
dataType: "json"
}
},
schema: {
model: {
id : "ehorsProgramID",
hasChildren: false,
children : "items"
}
},
filter: { field: "module", operator: "startswith", value: "Accounting" }
});
$("#AccountingTree").kendoTreeView({
check: onCheck,
checkboxes: { checkChildren: true } ,
dataSource: homogeneous,
dataBound: function(){
this.expand('.k-item');
},
dataTextField: ["module","groupname","ehorsProgramName"]
});
homogeneous1 = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: serviceRoot,
dataType: "json"
}
},
schema: {
model: {
id : "ehorsProgramID",
hasChildren: false,
children : "items"
}
},
filter: { field: "module", operator: "startswith", value: "Admin & System" }
});
$("#AdminSystemTree").kendoTreeView({
check: onCheck,
checkboxes: { checkChildren: true },
dataSource: homogeneous1,
dataBound: function(){
this.expand('.k-item');
},
dataTextField: ["module","groupname","ehorsProgramName"]
});
function toggleCheckAll() {
var checkButtonValue = $("#chbAll").val();
if(checkButtonValue == "Uncheck"){
$("#AccountingTree .k-checkbox-wrapper input").prop("checked", true).trigger("change");
$("#AdminSystemTree .k-checkbox-wrapper input").prop("checked", true).trigger("change");
} else {
$("#AccountingTree .k-checkbox-wrapper input").prop("checked", false).trigger("change");
$("#AdminSystemTree .k-checkbox-wrapper input").prop("checked", false).trigger("change");
}
}
function checkedNodeIds(nodes, checkedNodes) {
for (var i = 0; i < nodes.length; i++) {
if (nodes[i].checked) {
//checkedNodes.push(nodes[i].moduleID);
// checkedNodes.push(nodes[i].groupID);
checkedNodes.push(nodes[i].id);
}
if (nodes[i].hasChildren) {
checkedNodeIds(nodes[i].children.view(), checkedNodes);
}
}
}
function onCheck() {
var checkedNodes = [],treeView = $("#AccountingTree").data("kendoTreeView"),message;
var checkedNodes2 = [],treeView2 = $("#AdminSystemTree").data("kendoTreeView"),message;
checkedNodeIds(treeView.dataSource.view(), checkedNodes);
checkedNodeIds(treeView2.dataSource.view(), checkedNodes);
if (checkedNodes.length > 0) {
message = "IDs of checked nodes: " + checkedNodes.filter(x => !!x).join(",");
} else {
message = "No nodes checked.";
}
$("#result").html(message);
}