简体   繁体   中英

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. 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. 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.

Any Help would be appreciated.

you can define the URL for the data source.

This example comes from Telerik documentation.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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