来自Controller

时间:2016-02-29 09:56:12

标签: asp.net-mvc kendo-ui kendo-treelist

我像这样创建一个kendo TreeList

@(Html.Kendo().TreeList<BEL.EmpTreeBEL>()
    .Name("treelist")
    .Columns(columns =>
    {
        columns.Add().Field(e => e.EmpName).Width(250).Title("First Name");
        columns.Add().Field(e => e.EmpDept).Title("Departemen Name");
    })
    .DataSource(dataSource => dataSource
        .ServerOperation(false)
        .Read(read => read.Action("All", "Home"))
        .Model(m => {
            m.Id(f => f.EmpId);
            m.ParentId(f => f.ReportTo);
            m.Field(f => f.EmpName);
            m.Field(f => f.EmpDept);
            m.Field(f => f.ReportTo);
            m.Expanded(true);
        })
    )    
)

并从此

填充数据
public JsonResult All([DataSourceRequest] DataSourceRequest request)
        {
            var result = new EmployeeBLL().EmpListTree.ToTreeDataSourceResult(request,
                e => e.EmpId,
                e => e.ReportTo
            );

            return Json(result, JsonRequestBehavior.AllowGet);
        }

问题是,我的kendo TreeList只显示父级,而不显示子级

我从telerik文档中获取该代码,有一些我不理解的代码

var result = GetDirectory().ToTreeDataSourceResult(request,
                e => e.EmployeeID,
                e => e.ReportsTo,
                e => id.HasValue ? e.ReportsTo == id : e.ReportsTo == null,
                e => e.ToEmployeeDirectoryModel() //i don't understand this part
            );

我做错了什么? 我应该从javascript创建kendo TreeList吗?而不是使用Html.Kendo()。TreeList?

谢谢 抱歉我的英文不好

0 个答案:

没有答案