i am having an kendo treeview with checkbox template.
my html code
<div id="treeview-left" style=" height: 375px; position: absolute;top: 30px;"></div>
I have defined the treeview like:
var treeview1 = $('#treeview-left').kendoTreeView({
select: onSelect,
checkboxTemplate: kendo.template($("#treeview-checkbox-template").html()),
dragAndDrop: true,
dataSource: parent,
dataTextField: ["parentName", "childName"]
}).data("kendoTreeView");
And the checkbox template is defined like:
<script id="treeview-checkbox-template" type="text/kendo-ui-template">
<input type="checkbox" />
</script>
And the datasource will be
var parent = new kendo.data.HierarchicalDataSource({
type: "POST",
dataType: "json",
transport: {
read: {
url: "/Projects/leftdisplay"
}
},
schema: {
model: {
id: "parentid",
hasChildren: "childName",
children: child
}
}
});
now the child of the parent will be like:
var child = {
type: "POST",
dataType: "json",
transport: {
read: {
url: function (options) {
return kendo.format("/projects/modulesleftdisplay?parentid=" + options.parentid + "&roleid=" + rolevalue + "&projectid=" + projectid + "");
}
}
},
schema: {
model: {
id: "childid",
hasChildren: function () {
return false;
}
}
}
};
Now when i am clicking on the child checkbox i want to get the parent id of the selected child. How can i get that.
I have written code like
$("#treeview-left [type=checkbox]").live('change', function (e) {
var chkBox = $(this)
var parentid = chkBox.parent();
var date = $('#treeview-left').data('kendoTreeView').dataItem(parent_id);
var parid = date.id;
var childid = $('#treeview-left').data('kendoTreeView').dataItem(parentid);
});
but the parid is not getting. How can i get the parent id of the selected child. Any help is appreciated.