1
我想在Asp.Net MVC中绑定Kendo Grid,但分页不起作用。 PageSize和Total记录是正确的,问题是无法导航到下一页。所有按钮都显示,但它们被禁用。Kendo Grid Paging在Asp.Net MVC中不工作
视图的代码是:
<% 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();
%>
该控制器的代码:
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);
}
任何建议表示赞赏! 非常感谢您的帮助!
咪咪
使用F12检查您的ID字段并查看请求中是否使用了ID。我敢打赌,这可能不会被发送。 –
我不认为这条线是必需的。模型(model => model.Id(p => p.Id))。它只有当您使用网格的更新/插入/删除命令时才需要。 –
嗨,谢谢你的回答,但是当我从Controller .Read(read => read.Action(“GetParts”,“Claim”,new {id = Model.WoId})调用方法时 我看不到网格中没有任何东西;网格没有绑定,因为我不能像之前那样在参数中传递模型: <%Html.Kendo()。Grid(Model) \t .Name(“PartListGrid”)... (“PartListGrid”)... \t .Name(“PartListGrid”)... – user3470946