ASP MVC TreeView的Kendo UI:代表Tree显示Json响应
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ASP MVC TreeView的Kendo UI:代表Tree显示Json响应相关的知识,希望对你有一定的参考价值。
我试图显示具有远程数据绑定的类别树。这是Controller方法:
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结果(数组)。
我错过了什么吗?
答案
我明白了:我必须有一个Controller动作,它返回一个视图,然后从相关视图中调用kendo Html帮助器。
以上是关于ASP MVC TreeView的Kendo UI:代表Tree显示Json响应的主要内容,如果未能解决你的问题,请参考以下文章
使用 Kendo UI Asp.net mvc core 未显示图表组件
asp.net mvc kendo ui grid 加密列数据
用于 jquery CRUD 的 Asp.net core mvc + kendo ui