简体   繁体   English

每个面板栏项目操作都会重新加载Telerik MVC面板栏

[英]Telerik MVC Panel Bar getting reloaded for each Panel Bar Item action

I am using Telerik MVC Panel Bar as a side menu bar for my application. 我将Telerik MVC面板栏用作应用程序的侧面菜单栏。 I am referring this link Demo 我指的是此链接演示

I did bind(Local Data Binding) my Model to the Panel Bar, which is working fine. 我确实将我的模型绑定(本地数据绑定)到面板栏,效果很好。 My question is How do I make the Panel Bar Item.Action("Action","Controller") to be an AJAX call. 我的问题是如何使面板栏Item.Action(“ Action”,“ Controller”)成为AJAX调用。 Because every time I click on a menu my Page gets reloaded. 因为每次我单击菜单时,页面都会重新加载。

I am unable to find any solution for this in Telerik MVC section. 我无法在Telerik MVC部分中找到任何解决方案。

Any Help would be appreciated. 任何帮助,将不胜感激。

you can define the URL for the data source. 您可以定义数据源的URL。

This example comes from Telerik documentation. 此示例来自Telerik文档。

View 视图

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

Action in 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);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM