Problem with ToTreeDataSourceResult method when filtering on root and child level.
Also applying filtering causes a significant slowdown in the query created by the ToTreeDataSourceResult method even when applied to small datasets.
Please refer to the code below and simply filter the first column with the value of 5.
//View
@(Html.Kendo().TreeList<WebApplication1.Models.SerialModel>()
.Name("treelist")
.Toolbar(toolbar => toolbar.Create().Text("New Level"))
.Columns(columns =>
{
columns.Add().Field(e => e.RecordID).Width(280);
columns.Add().Field(e => e.SerialNumber).Width(160);
columns.Add().Field(e => e.Name);
columns.Add().Field(e => e.Location).Width(200);
columns.Add().Field(e => e.ParentID).Width(140);
columns.Add().Command(c =>
{
c.CreateChild().Text("New Child");
c.Edit();
c.Destroy();
}).Width(250);
})
.Editable(editable => editable.Mode("inline")).Filterable(true).Filterable(f => f.Extra(false))
.DataSource(dataSource => dataSource
.Read(read => read.Action("TreeListData", "Home"))
//.ServerOperation(false)
.Model(m =>
{
m.Id(f => f.RecordID);
m.ParentId(f => f.ParentID).DefaultValue("0");
})
)
.Height(540)
)
//Controller code:
public ActionResult TreeListData([DataSourceRequest]DataSourceRequest request, int? id)
{
var source = Enumerable.Range(1, 5).Select(x => new SerialModel()
{
RecordID = x,
SerialNumber = x,
Name = "Name " + x,
Location = "Location " + x,
hasChildren = true,
ParentID = x < 5 ? 0 : (x / 5)
});
return Json(source.ToTreeDataSourceResult(request, e => e.RecordID,
e => e.ParentID, e => id.HasValue ? e.ParentID == id : e.ParentID == 0, m => m));
}
Instead of 1 record it returns 2 same items.
Filtering of the TreeList should be as fast as sorting.