Reset to first page after sort or server side filtering

8 posts, 1 answers
  1. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 19 Dec 2012 Link to this post

    Hi,

    I am trying to get the grid to go back to page one on any sorting or filtering operation (ServerOperation=true) on an ajax enabled grid.  I noticed even the samples dont return to page one when sorting - it leaves you right on the same page.

    Right now I do this:
    $("#clients-grid").data("kendoGrid").dataSource.read()

    and it does a read, but leaves it on the page the user was last at.  How do I get this to go back to page 1?

    Thank you.
    David A
  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 20 Dec 2012 Link to this post

    Hello David,

    When filtering the grid widget will reset it's page index as the result set will be reduced. However when sorting this is not neccessary as the same page numbers should be available. Sorting does not reduce the result set/data items/.

    Regards,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 20 Dec 2012 Link to this post

    Thank you for your response Nikolay.  I am filtering externally from a search box and want the page index to be reset. If I am on page 3 and perform a datasource.read() which filters the results to 1 page, the grid stays on page 3 and is blank.  How can I force the grid to go to page 1?

    Thank you.
  4. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2289 posts

    Posted 20 Dec 2012 Link to this post

    Hello David,

    You should use DataSource.filter method in order to reset the page index.

    Regards,
    Nikolay Rusev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  5. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 21 Dec 2012 Link to this post

    Hello Nikolay.  Thank you again for your response but I didn't state my question clearly for which I apologize.  I have an external field that I am using to narrow the search results on and not using the grid filters.  I dug into the js source for grid and this seems to work:
    $("#clients-grid").data("kendoGrid").dataSource.page(1);


    It must refetch the data behind the scenes.
    David A

  6. Answer
    Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 25 Dec 2012 Link to this post

    Hello David,

    To combine several operation such as paging, filtering, grouping etc. within one request you can use the query method.

    Kind regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  7. David A.
    David A. avatar
    126 posts
    Member since:
    Aug 2008

    Posted 26 Dec 2012 Link to this post

    Thank you Petur.  That is exactly what I was looking for.
  8. Sivaramakrishna Reddy
    Sivaramakrishna Reddy avatar
    7 posts
    Member since:
    Mar 2020

    Posted 31 Mar 2020 in reply to David A. Link to this post

    Thank you. It is working for me.
Back to Top