Kendo Grid Paging在Asp.Net MVC中不起作用

时间:2014-03-28 02:28:42

标签: asp.net-mvc kendo-ui pagination grid

我正在尝试在Asp.Net MVC中绑定一个Kendo Grid,但是分页不起作用。 PageSize和Total记录是正确的,问题是导航到下一页是不可能的。显示所有按钮,但它们被禁用。

视图的代码是:

<% 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();                                        
%>

Controller的代码:

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

任何建议表示赞赏! 非常感谢你的帮助!

米米

1 个答案:

答案 0 :(得分:1)

我敢打赌你必须抛出数据源读取配置,以便数据集可以在需要时获取分页数据。

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