I tried multiple times with many different ways to get data to be read by TreeList. While searching around I stumbled discovered that people are using ToTreeDataSourceResult extension before sending the data as Json. What is in that extension and where can I get it ?
Trivial examples that should work, but does not:
public
ActionResult GetServiceList([DataSourceRequest] DataSourceRequest request, ServiceViewModel viewModel)
{
List<TestViewModel> result =
new
List<TestViewModel>()
{
new
TestViewModel()
{
Id = 1,
ParentId =
null
,
Name =
"Parent"
},
new
TestViewModel()
{
Id = 2,
ParentId = 1,
Name =
"Child"
}
};
return
Json(result, JsonRequestBehavior.AllowGet);
}
And in CSHTML:
@(Html.Kendo().TreeList<IMIS.FrontEnd.Areas.Policy.Models.TestViewModel>()
.Name(
"treelist"
)
.Columns(columns =>
{
columns.Add().Field(e => e.Name);
})
.Filterable()
.Sortable()
.DataSource(dataSource => dataSource
.Read(read => read.Action(
"GetServiceList"
,
"Health"
,
new
{Area=
"Policy"
}))
.ServerOperation(
false
)
.Model(m =>
{
m.Id(f => f.Id);
m.ParentId(f => f.ParentId).DefaultValue(
null
);
m.Expanded(
true
);
m.Field(f => f.Name);
}) ).Height(540))
This example should make trivial Tree list, but it does nothing even though the Json data is passed. Is it because I am not using that extension ?