We are migrating our application from the ASP.NET AJAX Grid, where we had the PageCount in the Pager-Message as stated here:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/functionality/paging/changing-the-default-pager/using-pagertextformat
{1} is total number of pages.
Unfortunately, the Pager of the Kendo Grid does not support the PageCount.
http://docs.telerik.com/kendo-ui/api/javascript/ui/pager#configuration-messages.display
Is there any workaround to get the pageCount in the pager?
4 Answers, 1 is accepted
Although including the total number of pages in the Kendo UI Grid pagination section is not possible out of the box, the DataSource API does offer a method that returns the total number of pages; you can read more about totalPages here.
I have prepared a sample in the Kendo UI Dojo to see how it can be obtained. In the databound event of the grid the following line displays the total number of pages in the console:
console.log($(
"#grid"
).data(
"kendoGrid"
).dataSource.totalPages());
I hope this helps!
Regards,
Eduardo Serra
Telerik by Progress
Hello,
thank you for your input.
I've tried your approach.
In the pager I set the message to <span class="grid-pagecount" /> so that an empty span will be rendered.
Then in the dataBound event I get the reference to the span and tried to set the dataSource.totalPages(). Unfortunately, the pager message is rendered after the databound event. So I can't set the span from this event..
Do you have any further help on this issue?
Best regards,
Daniel
You're right, the pager message is rendered after the dataBound event. I was able to set the total number of pages on the pager message in the document.ready function, but that brings us the problem of the number disappearing when the page changes.
If you want to follow that approach I could recommend you using a timeout; I have prepared a sample in the Kendo UI Dojo showing how this could work, take a look at it here.
I hope this helps!
Regards,
Eduardo Serra
Telerik by Progress
This works, thank you very much for your support. :)
Best regards,
Daniel