1
votes

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

1

1 Answers

1
votes

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