Hi,
I have a requirement to bind data to TreeList where Id and ParentId field are of type string but this does not seem to work. Is it possible?
I have tried making id and parentId field int and then its works.
TreeList:
<div class="demo-section k-header"> @(Html.Kendo().TreeList<JobErrorLogController.MyClass>() .Name("myClassTreelist") .Columns(columns => { columns.Add().Field(e => e.Item).Width(220); }) .Filterable() .Sortable() .DataSource(dataSource => dataSource .Read(read => read.Action("AllData", "JobErrorLog")) .ServerOperation(false) .Model(m => { m.Id(f => f.id); m.ParentId(f => f.parentId); //m.Expanded(true); m.Field(f => f.Item); }) ) .Height(540) )</div>Class that is bind to TreeList:
public class MyClass { public static IList<MyClass> TestData = new List<MyClass>() { new MyClass() {id = "parent1", Item = "Item0", parentId = null}, new MyClass() {id = "child1", Item = "Item1", parentId = "parent1"} }; public string id { get; set; } public string parentId { get; set; } public string Item { get; set; } }Controller's code:
public JsonResult AllData([DataSourceRequest] DataSourceRequest request) { var result = MyClass.TestData.ToTreeDataSourceResult(request, e => e.id, e => e.parentId ); return Json(result, JsonRequestBehavior.AllowGet);
}