Hi,
I created a project and i need to put a treelist view to handle parents and child elements of a grid. I created a father and a child, but the page doesn't load any record in my grid. Am i missing something?
The attached files are the grid viewed in my page and the model received from the datasource
Here is the model
public class ProjectTaskViewModel
{
public string IdTask { get; set; }
public string FatherId { get; set; }
public string TaskTitle { get; set; }
}
The View:
@(Html.Kendo().TreeList<
Models.ProjectTaskViewModel
>()
.Name("treelist")
.Columns(columns =>
{
columns.Add().Field(p => p.IdTask).Title(" ").Filterable(false).Sortable(false).Width("105px").Template("#=customformatter(Id)#");
columns.Add().Field(p => p.TaskTitle).Title("Nsme");
})
.Pageable(p => p.Refresh(true).PageSize(20).PageSizes(new int[] { 20, 50, 100 }))
.Sortable()
.Filterable()
.DataSource(dataSource => dataSource
.Read(read => read.Action("TreeViewDataSource", "ProjectTask").Data("CustomData")) //Function that contains correctly the IdProject param
.ServerOperation(false)
.Model(m => {
m.Id<
string
>(p => p.IdTask);
m.ParentId<
string
>(p => p.FatherId);
m.Field(p => p.TaskTitle);
m.Field<
string
>(p => p.FatherId);
})
)
)
And finally the TreeViewDataSource:
public JsonResult TreeViewDataSource([DataSourceRequest]DataSourceRequest request, string IdProject)
{
var temp = _db.ProjectTasks.Where(o => o.IdProject == IdProject).Select(o => new ProjectTaskViewModel
{
FatherId = o.ParentId,
IdTask = o.Id,
TaskTitle = o.Title
});
var result = temp.ToTreeDataSourceResult(request, o => o.IdTask, o => o.FatherId, o => o);
return Json(result);
}