简体   繁体   中英

Kendo Grid Paging doesn't work in Asp.Net MVC

I am trying to bind a Kendo Grid in Asp.Net MVC but the paging doesn't work. The PageSize and the Total records are correct, the problem is that it isn't possible to navigate to the next page. All the buttons are displayed but they are disabled.

The view's code is:

<% Html.Kendo().Grid(Model)
        .Name("PartListGrid")
        .Columns(columns =>
        {
            columns.Bound(p => p.Id).Title("Id").Visible (false);
            columns.Bound(p => p.Quantity).Title("Quantity")).Width(130);
            columns.Bound(p => p.PartNumber).Title("Part Number").Width(130);
        })
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(p=>p.Id))
            .PageSize(5)
            .ServerOperation(false)
        )
        .Pageable()
        .Render();                                        
%>

The Controller's code :

public ActionResult GetPartListInfo(string id)
{                 
    List<PartListViewModel> partList = new List<PartListViewModel>();
    XrmServiceContext xrmServiceContext = new XrmServiceContext();
    f1_workorder workOrder = xrmServiceContext.f1_workorderSet.Where(i => i.Id == new Guid(workOrderId)).FirstOrDefault();
    PartListViewModel partViewModel = null;

    foreach (f1_workorderproduct workorderproduct in xrmServiceContext.f1_workorderproductSet.Where(i => i.f1_WorkOrder.Id == workOrder.Id).ToList())
    {
        Product product = xrmServiceContext.ProductSet.Where(j => j.Id == workorderproduct.f1_Product.Id).FirstOrDefault();

        partViewModel = new PartListViewModel();
        partViewModel.Id = workorderproduct.f1_Product.Id.ToString();  
        partViewModel.Quantity = workorderproduct.f1_EstimateQuantity.GetValueOrDefault(0);
        partViewModel.PartNumber = workorderproduct.f1_name;                              

        partList.Add(partViewModel);     
    }    

    return View("PartList",partList);
}

Any advice is appreciated! Thank you very much for your help!

Mimi

I bet you have to throw in a data source read configuration so that the dataset can fetch the data on paging when needed.

.DataSource(dataSource => dataSource
    ...
    .Read(read => read.Action("YourAction", "YourController))
    ...

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