0

我正在使用 Telerik MVC 面板栏作为我的应用程序的侧边菜单栏。我指的是这个链接演示

我确实将我的模型绑定(本地数据绑定)到面板栏,它工作正常。我的问题是如何使面板栏 Item.Action("Action","Controller") 成为 AJAX 调用。因为每次我点击菜单时,我的页面都会重新加载。

我无法在 Telerik MVC 部分找到任何解决方案。

任何帮助,将不胜感激。

4

1 回答 1

1

您可以定义数据源的 URL。

这个例子来自 Telerik 文档。

看法

@(Html.Kendo().PanelBar()
    .Name("panelbar")
    .DataTextField("Name")
    .DataSource(dataSource => dataSource
        .Read(read => read
            .Action("GetEmployeesJson", "Controller")
        )
    )
)

控制器中的动作

 public JsonResult GetEmployeesJson(int? id)
    {
        var dataContext = new SampleEntities();

        var employees = from e in dataContext.Employees
                        where (id.HasValue ? e.ReportsTo == id : e.ReportsTo == null)
                        select new
                        {
                            id = e.EmployeeID,
                            Name = e.FirstName + " " + e.LastName,
                            hasChildren = e.Employees1.Any()
                        };

        return Json(employees, JsonRequestBehavior.AllowGet);
    }
于 2018-10-12T12:41:44.360 回答