Ashwin
Ashwin

Reputation: 12431

kendo grid specify page count

I have a Kendo grid. On that grid there is a pagination which has message.

pageable: {
    messages: {
        display: {2} - records found, displaying {0} to {1}
    }
}

where, {0} - first index of the record on that page
{1} - last index of the record on that page
{2} - total number of records which I want to specify in response

How will be the structure of the response that is what i want to know. I checked on grid documentation from Kendo - http://docs.kendoui.com/api/framework/datasource#methods-total. But could not find much help. Any help is greatly appreciated.

Upvotes: 1

Views: 3683

Answers (1)

OnaBai
OnaBai

Reputation: 40917

In the request, KendoUI by default will be sending the following information:

  • page - the page of data item to return (1 means the first page)
  • pageSize - the number of items to return
  • skip - how many data items to skip
  • take - the number of data items to return (the same as pageSize)

And the data return should provide a total.

Example: We have requested page 1 and pageSize: 5. Our returned data should look like:

{
    total: 300,
    data : [
        { ... },
        { ... },
        { ... },
        { ... },
        { ... }
    ]
}

So the DataSource definition should be:

dataSource: {
    transport   : {
        read: {
            url : "..."
        }
    },
    serverPaging: true,
    pageSize    : 10,
    schema      : {
        model: {
            id    : "id",
            fields: {
               ...
            }
        },
        data : "data",
        total: "total"
    }
},

Upvotes: 2

Related Questions