Support for PageCount-Variable in Pager

5 posts, 0 answers
  1. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 12 Jan 2017 Link to this post

    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?

  2. Eduardo Serra
    Admin
    Eduardo Serra avatar
    119 posts

    Posted 13 Jan 2017 Link to this post

    Hello Daniel,

    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
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 14 Jan 2017 in reply to Eduardo Serra Link to this post

    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

  4. Eduardo Serra
    Admin
    Eduardo Serra avatar
    119 posts

    Posted 16 Jan 2017 Link to this post

    Hello 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
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Daniel Grünberger
    Daniel Grünberger avatar
    55 posts
    Member since:
    May 2008

    Posted 18 Jan 2017 in reply to Eduardo Serra Link to this post

    This works, thank you very much for your support. :)

    Best regards,

    Daniel

Back to Top