任何人都可以告诉我如何使用客户端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分页
DataSource配置设置