kendoui for aspmvc treeview:代表树显示JSON响应



我正在尝试显示具有远程数据绑定的类别树。这是控制器方法:

    public JsonResult KendoTree(Guid? id)
    {
        var categoriesBO = _categoryManager.GetAllCategory().
            Where(c=> id==null ? c.ParentId==null : c.ParentId == id).
            Select(c=> new
            {
                id = c.Id,
                Name = c.Name,
                hasChildren = c.CategoryChilds.Any()
            });
        return Json(categoriesBO, JsonRequestBehavior.AllowGet);
    }

这是CSHTML文件

    @{
    ViewBag.Title = "KendoTree";
}
    <h2>KendoTree</h2>
    @Html.Kendo().TreeView().Name("Categories").DataSource(dataSource => dataSource
        .Read(read => read.Action("KendoTree", "CategoryManagement")
    )).DataTextField("Name")

浏览器代表树显示JSON结果(数组)。

我想念什么吗?

我得到了:我必须有一个控制器操作,该操作返回视图,然后从相关视图内调用kendo html助手。

最新更新