[英]Kendo MVC TreeList not Rendering from Initial BindTo
My MVC ViewModel
contains the initial list of records to be displayed within my Kendo
TreeList
. 我的
MVC ViewModel
包含要在Kendo
TreeList
显示的记录的初始列表。 However, the TreeList is NOT rendering the initial list...and I don't understand why. 但是,TreeList没有呈现初始列表...而且我不明白为什么。
REQUIREMENTS: 要求:
For other Kendo controls, you set: 对于其他Kendo控件,您可以设置:
...and the READ ACTION does not execute. ...并且READ ACTION不执行。 But the TreeList is failing at the moment.
但是TreeList目前正在失败。
MY RAZOR LOOKS LIKE: 我的剃刀外观很像:
At initial render records DO EXIST (see image below) 最初的渲染记录确实存在(请参见下图)
@(Html.Kendo().TreeList<DeviceHierarchyDataItem>()
.Name("treeTarget")
.Columns(columns =>
{
columns.Add().Field(e => e.DisplayName)
.TemplateId("tmplDisplayName")
.Title(" ");
})
.BindTo(Model.TargetDevices)
.AutoBind(false)
.DataSource(dataSource => dataSource
.Read(read => read.Action("find", "devicehierarchy", new { Area = "" })
.Data("window.etp.pageController.getFilter"))
.ServerOperation(false)
.Model(m =>
{
m.Id(f => f.Id);
m.ParentId(f => f.ChildOf);
m.Expanded(true);
m.Field(f => f.DisplayName);
}))
.Sortable())
Strangely enough the TreeList MVC control doesn't support binding to local data... At least not in july 2018 ... 奇怪的是TreeList MVC控件不支持绑定到本地数据...至少在2018年7月不 ...
The recommendation is to use the jquery control instead. 建议使用jquery控件代替。
And then convert the data from the Model to a json string: 然后将数据从模型转换为json字符串:
$(document).ready(function () {
var dataSource = new kendo.data.TreeListDataSource({
data: @Html.Raw(Json.Encode(@Model.TargetDevices)),
schema: {
model: {
id: "Id",
parentid: "ChildOf",
expanded: true
}
}
});
I hope it helps! 希望对您有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.