gpt4 book ai didi

asp.net-mvc - 如何在ASP.NET MVC中的客户端Kendo UI网格中实现服务器端分页

转载 作者:行者123 更新时间:2023-12-03 10:09:29 27 4
gpt4 key购买 nike

谁能告诉我如何使用客户端Kendo UI Grid实现服务器端分页?

最佳答案

UPDATE: We have released an open source .NET library which makes paging, sorting an filtering a lot easier.


一旦将 pageSize设置为 skip,网格将发送当前的 serverPagingtrue。在服务器端,您应该使用提供的信息来分页数据,并将其与项目总数一起返回。这是一个代码片段:
行动
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 });
}
}
View
$("#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
}
});
引用
使用LINQ分页
  • Take() and Skip()

  • 数据源配置设置
  • serverPaging
  • schema.data
  • schema.total
  • 关于asp.net-mvc - 如何在ASP.NET MVC中的客户端Kendo UI网格中实现服务器端分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12928744/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com