剑道UI网格上的分页不起作用

Pagination on Kendo UI Grid is not working

本文关键字:分页 不起作用 UI 网格 剑道      更新时间:2023-09-26

我正在显示一个包含远程数据的网格,如果我不添加分页,则会显示完整的数据集,当然这是不希望的。

以下是我用来在网格上显示数据的代码:

var ds = new kendo.data.DataSource({
    transport: {
        read: {
            url: "http://127.0.0.1:81/SismosService.svc/usuario/index",
            dataType: "json"
        }
    },
    schema: {
        data: "Response"
    },
    pageSize: 5
});
$("#usuariosGrid").kendoGrid({
    pageable: {
        refresh: true
    },
    columns: [
        { field: "UsuarioId", title: "ID", width: "100px" },
        { field: "Nombre", title: "Nombre", width: "100px" },
        { field: "ApellidoP", title: "Apellido Paterno", width: "100px" },
        { field: "ApellidoM", title: "Apellido Materno", width: "100px" },
        { command: [{ text: "Editar", click: editFunction }, { text: "Eliminar", click: deleteFunction }], title: " ", width: "200px" }
    ],
    dataSource: ds
});

这渲染了一个有5个项目的网格,但仅此而已,我无法浏览其余的条目。要显示的页数和项目数标记为零,从而禁用导航控件。

我是不是在自己的形象中遗漏了什么?感谢您提供的任何帮助。

在服务器中进行分页时(检查serverpage),需要返回记录总数。有关信息,请参见total

我也遇到了同样的问题,因为我误解了serverPaging。如果将serverPaging设置为true,则还必须修改服务器返回的内容。

以前,我让服务器返回所有数据。为了解决这个问题,我使用ToDataSourceResult来修改服务器返回的内容。

请参阅:如何在asp.net的客户端Kendo UI网格中实现服务器端分页mvc

花一天时间处理这个小问题,您所要做的就是返回记录的总数,如果您的服务没有返回记录的总量,请执行以下

schema: {
        data: "Response"
    },
total: function(response)
      {
        return response."your method name".length;
      }