Asp.net mvc 让Kendo treeview开始工作
所以我试图得到一个简单的剑道树视图来绑定到JSON数据,但我遇到了一个困难。你知道为什么这样不行吗?我在JSON结果代码上加了一个断点,但它从来没有触发过 我的HTML:Asp.net mvc 让Kendo treeview开始工作,asp.net-mvc,kendo-ui,treeview,kendo-treeview,Asp.net Mvc,Kendo Ui,Treeview,Kendo Treeview,所以我试图得到一个简单的剑道树视图来绑定到JSON数据,但我遇到了一个困难。你知道为什么这样不行吗?我在JSON结果代码上加了一个断点,但它从来没有触发过 我的HTML: @(Html.Kendo().TreeView() .Name("treeview") // The property that specifies the text of the node
@(Html.Kendo().TreeView()
.Name("treeview")
// The property that specifies the text of the node
.DataTextField("Name")
.LoadOnDemand(true)
.DataSource(dataSource => dataSource
.Read(read => read
// The action method which will return JSON
.Action("ReadCats", "Entity")
.Data("Id")
)
)
)
我的控制器:
public JsonResult ReadCats(int? id)
{
var categories = _entityLogic.GetActiveCategories();
var jsonResult = categories.Select(cat => new
{
Id = cat.Id,
Name = cat.Name,
HasChildren = categories.Where(c => c.ParentCategory == cat.Id).Any(),
ParentId = cat.ParentCategory
}).ToList();
return Json(jsonResult, JsonRequestBehavior.AllowGet);
}
现在,如果我浏览到myapplication/Admin/Entity/ReadCats
,我确实会返回JSON数据。正如我所说,当我加载树所在的视图时,断点永远不会命中
有什么想法吗?我注意到,我已经尝试了
.Action(“ReadCats”,“Entity”)
的每一种变体,我可以想到这样的:.Action(“ReadCats”,“Admin/Entity”)
,.Action(“ReadCats”,“~/Admin/Entity”)
,等等。如果你使用Chrome的F12开发工具,也许你可以在前端添加一个断点。你也试过Fiddler开发应用程序直接调用你的控制器吗?