加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

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

发布时间:2020-12-15 18:47:37 所属栏目:asp.Net 来源:网络整理
导读:任何人都可以告诉我如何使用客户端Kendo UI Grid实现服务器端页面? 解决方法 UPDATE: We have 07000 an open source .NET library which makes paging,sorting an filtering a lot easier. 将gridPaging设置为true后,网格将发送当前pageSize并跳过。在服务
任何人都可以告诉我如何使用客户端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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读