剑道UI专家请帮助我..
我是剑道ui的新手。我想在我的代码中返回剑道树视图中选定节点的 id。但它只返回相同的节点。
在选择节点时,我想将所选节点的 id 返回到我的代码,并且在代码中我返回该节点的子元素。
有什么简单的方法吗??
提前致谢..
我的代码
<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>
homecontroller的datasourcefortree方法及代码
[HttpPost]
public JsonResult datasourcefortree(int? NodeID)
{
FNHSessionManager sessionManager = new FNHSessionManager(_connString, FNHSessionManager.DatabaseType.MsSql);
FNHRepository repository = new FNHRepository(sessionManager);
int nodevalue = 1;
if (NodeID == null)
{
ResourceMaster tree = repository.RetrieveById(nodevalue);
List node = new List{
new ResourceMaster
{
ResourceID = tree.ResourceID,
Resource=tree.Resource
}
};
return Json(node, JsonRequestBehavior.AllowGet);
}
else
{
if (NodeID.HasValue)
{
nodevalue = NodeID.Value;
IList childtreenode = repository.GetAllRecord(nodevalue);
return Json(childtreenode, JsonRequestBehavior.AllowGet);
}
return (null);
}
}