Pan*_*kaj 27 asp.net-mvc kendo-ui
任何人都可以告诉我如何使用客户端Kendo UI Grid实现服务器端分页?
Ata*_*hev 60
更新:我们已经发布了一个开源.NET库,它使分页,过滤分类变得更加容易.
该网格将发送当前pageSize和skip一旦你设置serverPaging到true.在服务器端,您应使用提供的信息对数据进行分页,并将其与项目总数一起返回.这是一段代码:
public ActionResult Products(int pageSize, int skip)
{
using (var northwind = new NorthwindDataContext())
{
var products = northwind.Products;
// Get the total number of records - needed for paging
var total = products.Count();
// Page the data
var data = products.Skip(skip).Take(pageSize).ToList();
// Return as JSON - the Kendo Grid will use the response
return Json(new { total = total, data = data });
}
}
Run Code Online (Sandbox Code Playgroud)
$("#grid").kendoGrid({
dataSource: {
transport: {
read: {
url: "home/products",
dataType: "json",
type: "POST"
}
},
schema: {
data: "data", // records are returned in the "data" field of the response
total: "total" // total number of records is in the "total" field of the response
},
serverPaging: true // enable server paging
}
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
57251 次 |
| 最近记录: |