Reputation: 47
i have been using kendo tree view for navigation purpose in my mvc project and all my datas are coming from db i had made remote binding to tree view and data bind is perfect.but the problem is i got only the first node and on expanding the first node all its child node are loading i want all the child node to loaded on the time of page load.is there any way to do it .here is my kendo control
@Html.Kendo()
.TreeView()
.Name("myThings")
.DataSource(dataSource => dataSource
.Read(read => read.Action("Index", "Employees"))
).DataTextField("Name")
and my controller code is
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()
}
);
Upvotes: 0
Views: 2204
Reputation: 40887
Kendo UI documentation on TreeView
configuration property loadOnDemand
says:
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.
Consider using it.
Upvotes: 0