Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pagination on Kendo UI Grid is not working

I'm displaying a grid with remote data, if I don't add pagination the full set of data is displayed, of course this is not desired.

The following is the code I'm using to display data on a grid:

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

This renders a grid with 5 items on it, but that's it, I can't navigate through the rest of the entries. The number of pages and items to display is marked as zero, disabling the navigation controls.

Am I missing something in my cofiguration? Thanks for any help you can provide.

like image 458
Uriel Arvizu Avatar asked Feb 11 '13 22:02

Uriel Arvizu


2 Answers

When paging is done in the server (check serverpaging), you need to return the total number of records. See total for information.

like image 169
OnaBai Avatar answered Oct 20 '22 03:10

OnaBai


I had the same issue because I misunderstood serverPaging. If you set serverPaging to true, you also have to modify what the server returns.

Previously, I had the server returning all of the data. To fix this, I used ToDataSourceResult to modify what my server returns.

See: How to implement Server side paging in Client side Kendo UI grid in asp.net mvc

like image 41
Elaine Lin Avatar answered Oct 20 '22 03:10

Elaine Lin