如何在 Telerik MVC TreeView (Kendo UI) 的 TreeView 中访问模型 属性
How to access a Model property in a TreeView on Telerik MVC TreeView (Kendo UI)
当我 select 树视图节点之一时,如何访问模型的 ID 属性? (我想在树视图旁边显示基于 ID 的详细信息)
@(Html.Kendo().TreeView()
.Name("OrganizationTree")
.HtmlAttributes(new { @class = "demo-section" })
.DataTextField("Name")
.DragAndDrop(true)
.ExpandAll(true)
.Events(events => events
.Select("onOrgSelect")
.Drop("onOrgDrop")
)
.DataSource(dataSource => dataSource
.Model(m=> m
.Id("ID")
.HasChildren("HasChildren")
)
.Read(read => read
.Action("Organizations_Read", "Organizations")
)
)
)
这是 javascript 函数:
function onOrgSelect(e)
{
var id = $("#" + e.node.id).?????;
GetOrganization(id);
}
查看常用操作题目here。
function onSelect(e) { // this refers to the TreeView object var dataItem = this.dataItem(e.node);
console.log("Selected node with id=" + dataItem.id);
}
$("#treeview").kendoTreeView({ dataSource: [ { id: 1, text: "Item 1", items: [ { id: 3, text: "Item 3" } ] }, { id: 2, text: "Item 2" } ], select: onSelect });
当我 select 树视图节点之一时,如何访问模型的 ID 属性? (我想在树视图旁边显示基于 ID 的详细信息)
@(Html.Kendo().TreeView()
.Name("OrganizationTree")
.HtmlAttributes(new { @class = "demo-section" })
.DataTextField("Name")
.DragAndDrop(true)
.ExpandAll(true)
.Events(events => events
.Select("onOrgSelect")
.Drop("onOrgDrop")
)
.DataSource(dataSource => dataSource
.Model(m=> m
.Id("ID")
.HasChildren("HasChildren")
)
.Read(read => read
.Action("Organizations_Read", "Organizations")
)
)
)
这是 javascript 函数:
function onOrgSelect(e)
{
var id = $("#" + e.node.id).?????;
GetOrganization(id);
}
查看常用操作题目here。
function onSelect(e) { // this refers to the TreeView object var dataItem = this.dataItem(e.node);
console.log("Selected node with id=" + dataItem.id);
}
$("#treeview").kendoTreeView({ dataSource: [ { id: 1, text: "Item 1", items: [ { id: 3, text: "Item 3" } ] }, { id: 2, text: "Item 2" } ], select: onSelect });