Sort with javascript - reset pager

2 posts, 0 answers
  1. Justin Lee
    Justin Lee avatar
    154 posts
    Member since:
    Dec 2009

    Posted 09 Feb Link to this post

    Hello,

    I have a grid where I am changing the sort in javascript when a certain action is performed.

    The grid is paged, and when the sort occurs, it stays on the same page. I want the pager to reset (back to page 1).

    This could be accomplished by:

    var grid = $("#grid").data("kendoGrid");
    grid.dataSource.sort({ field: "Name", dir: "asc" });
    grid.dataSource.page(1);

    However - both the sort and page methods cause the grid to refresh. (Read)  Is there a way to avoid the multiple refreshes?  i.e. Set the sort without refreshing the grid, then calling page(1) to refresh the grid?

  2. Eduardo Serra
    Admin
    Eduardo Serra avatar
    90 posts

    Posted 09 Feb Link to this post

    Hello Justin,

    In order to avoid multiple refreshes when trying to sort, filter, or page, it is recommended to use the query method of the Kendo UI DataSource; you can read more about it here.

    This method will allow you to send the sort parameters and the desired page all at once.

    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.
Back to Top