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