【发布时间】:2014-02-18 06:12:43
【问题描述】:
我想在 Kendo Grid 中进行客户端网格分页。在网格中,只有前 50 或 100 个数据将显示在第一页中。当客户点击下一页时,将显示其他 50 或 100 条数据。我不想从我的服务器获取所有数据。因为数据库中会有数百万个数据,客户不想等待服务从服务器获取所有数据。当他/她点击下一页时,其他数据应该从服务器请求。我该怎么做?
我的控制器
[HttpGet]
public JsonResult Getdata()
{
var reports = db.ActivityLog.OrderBy(c => c.dateTime).ToList();
var collection = reports.Select(x => new
{
username = x.uName,
location = x.locName,
devices = x.devName
});
return Json(collection, JsonRequestBehavior.AllowGet);
}
我的看法 函数handleDataFromServer() {
$("#grid").data("kendoGrid").dataSource.read();
}
window.setInterval("handleDataFromServer()", 10000);
$(document).ready(function () {
$("#grid").kendoGrid({
sortable: true,
pageable: {
input: true,
numeric: false
},
selectable: "multiple",
dataSource: {
transport: {
read: "/Home/Getdata",
type: "json"
}
},
columns: [
{ field: "username", width: "80px" },
{ field: "location", width: "80px" },
{ field: "devices", width: "80px" }]
});
});
【问题讨论】:
标签: asp.net-mvc kendo-grid client-side paging