我有一个网格,我正在尝试将数据绑定到其工作文件中,如果记录数量较少,但对于大型记录,在我的情况下3490无法绑定数据
$("#addCustomer_Admin").click(function () {
debugger;
$.ajax({
url: '@Url.Action("GetAllUnAssignedUnits", "Admin")',
dataType: "json",
type: "POST",
success: function (result) {
debugger;
BindUnitsGrid(result);
},
error: function (result) {
debugger;
}
});
});
function BindUnitsGrid(data) {
debugger;
$("#CustomerUnitsGrid").kendoGrid({
dataSource: {
data: data,
schema: {
model: {
fields: {
UnitID: { type: "number" },
Nickname: { type: "string" },
SerialNumber: { type: "string" },
UnitType: { type: "string" },
Address1: { type: "string" },
City: { type: "string" },
Region: { type: "string" },
PostalCode: { type: "string" }
}
}
},
pageSize: 20,
},
sortable: true,
filterable: true,
columnMenu: true,
pageable: true,
columns: [
{ field: "UnitID", title: "UnitID" },
{ field: "Nickname", title: "Nickname" },
{ field: "SerialNumber", title: "SerialNumber" },
{ field: "UnitType", title: "UnitType" },
{ field: "Address1", title: "Address1" },
{ field: "City", title: "City" },
{ field: "Region", title: "Region" },
{ field: "PostalCode", title: "zip", hidden: true }
]
});
}
并在我的控制器中:
[HttpPost]
public async Task<ActionResult> GetAllUnAssignedUnits()
{
int UnKnownCutomerID = Convert.ToInt32(ConfigurationManager.AppSettings["UnknownCustomerID"]);
if (Session["custUserID"] != null)
{
try
{
var list = await _unitRepo.GetUnassignedUnits(UnKnownCutomerID);
return Json(list, JsonRequestBehavior.AllowGet);
}
catch (Exception exe)
{
Log objLog = new Log();
objLog.LogError(exe.InnerException.ToString());
return RedirectToAction("ShowError", "Error");
}
}
else
{
return RedirectToAction("Index", "Account");
}
}
这个
还有其他办法吗?答案 0 :(得分:1)
是的,还有其他选择。我肯定会建议大量对象的服务器端分页,因为这是一个巨大的json数组来管理。我建议以下帖子来实现服务器端分页。
How to implement Server side paging in Client side Kendo UI grid in asp.net mvc