Hello ,
Kendo UI experts Please help me..
I am new to Kendo ui. I want to return id of Selected node in kendo treeview in my code.
but it is returning only same node.
On selecting Node i want to return id of selected Node to my code, and in Code i am returning
child elements of that node.
is there any simple way of doing it??
Thanks in advance..
My Code
<div id="treeview"></div>
<script src="~/Scripts/kendo.treeview.min.js"></script>
<script>
homogeneous = new kendo.data.HierarchicalDataSource({
transport: {
read: {
url: "@Url.Action("datasourcefortree", "Home")",
type: "POST",
dataType: "json"
}
},
schema: {
model: {
id: "ResourceID",
hasChildren: true
}
}
});
$("#treeview").kendoTreeView({
dataSource: homogeneous,
dataTextField: "Resource"
});
</script>
and code of datasourcefortree method of homecontroller
[HttpPost]
public JsonResult datasourcefortree(int? NodeID)
{
FNHSessionManager<resourcemaster> sessionManager = new FNHSessionManager<resourcemaster>(_connString, FNHSessionManager<resourcemaster>.DatabaseType.MsSql);
FNHRepository<resourcemaster> repository = new FNHRepository<resourcemaster>(sessionManager);
int nodevalue = 1;
if (NodeID == null)
{
ResourceMaster tree = repository.RetrieveById(nodevalue);
List<resourcemaster> node = new List<resourcemaster>
{
new ResourceMaster
{
ResourceID = tree.ResourceID,
Resource=tree.Resource
}
};
return Json(node, JsonRequestBehavior.AllowGet);
}
else
{
if (NodeID.HasValue)
{
nodevalue = NodeID.Value;
IList<resourcemaster> childtreenode = repository.GetAllRecord(nodevalue);
return Json(childtreenode, JsonRequestBehavior.AllowGet);
}
return (null);
}
}