asp.net-mvc - Kendo Treeview 远程数据所有节点最初加载

标签 asp.net-mvc kendo-ui kendo-treeview

我一直在我的 mvc 项目中使用 Kendo Treeview 进行导航,我所有的数据都来自 db 我已经远程绑定(bind)到 Treeview 并且数据绑定(bind)是完美的。但问题是我只有第一个节点并且在扩展第一个节点所有子节点都在加载我希望所有子节点在页面加载时加载。有没有办法做到这一点。这是我的 Kendo 控制@Html.Kendo().TreeView().Name("myThings").DataSource(dataSource => dataSource .Read(read => read.Action("Index", "Employees") )).DataTextField("Name") 和我的 Controller 代码
var employees = _context.Employees .Where(e => id.HasValue ? e.ReportsTo == id : e.ReportsTo == null) .Select(e => new { id = e.EmployeeID, Name = e.FirstName + " " + e.LastName, hasChildren = e.Employees1.Any() });

最佳答案

TreeView 上的 Kendo UI 文档配置属性 loadOnDemand 说:

Indicates whether the child datasources should be fetched lazily when parent groups get expanded. Setting this to false causes all child dataSources to be loaded at initialization time. Note: when initializing the widget from an array (rather than from a HierarchicalDataSource instance), this option defaults to false, rather than true.



考虑使用它。

关于asp.net-mvc - Kendo Treeview 远程数据所有节点最初加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24243600/

相关文章:

c# - ASP.net Web API : change class name when serializing

asp.net-mvc - 同一页面中的 2 kendo ui Treeview 未扩展节点

c# - 数据驱动的asp.net mvc布局

kendo-ui - 如何卡住 Kendo MVC Grid 中的列标题?

grid - 剑道 UI 网格 : possible to allow grouping on specified columns and not on other columns

kendo-ui - 在 Kendo Ui 中如何将 GridView 中发生的变化反射(reflect)到图表上?

javascript - 在 Transport.read 函数中访问 dataItem

kendo-ui - 如何从 Kendo 中的对话框或窗口(弹出)导出网格的excel

jquery - Controller 的 HttpPost 操作被命中两次

html - Razor 绑定(bind)值到 Glyphicon 的 CSS 类