This is a migrated thread and some comments may be shown as answers.

Sort with javascript - reset pager

1 Answer 156 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin Lee
Top achievements
Rank 1
Justin Lee asked on 09 Feb 2017, 02:18 PM

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?

1 Answer, 1 is accepted

Sort by
0
Eduardo Serra
Telerik team
answered on 09 Feb 2017, 03:47 PM
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.
Tags
Grid
Asked by
Justin Lee
Top achievements
Rank 1
Answers by
Eduardo Serra
Telerik team
Share this question
or