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

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – 如何在客户端Kendo UI网格中实现服务器端分页在asp.net mvc中前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
任何人都可以告诉我如何使用客户端Kendo UI Grid实现服务器端页面

解决方法

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

将gridPaging设置为true后,网格将发送当前pageSize并跳过。在服务器端,您应该使用提供的信息页面您的数据,并将其与总数量一起返回。以下是代码段:

行动

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 });
     }
}

视图

$("#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()

DataSource配置设置

> serverPaging
> schema.data
> schema.total

原文链接:https://www.f2er.com/aspnet/253876.html

猜你在找的asp.Net相关文章