Andrew Daniel
Andrew Daniel

Reputation: 718

GridX clear the sort without making new request

I am using GridX to display data, but I often change the data store that the GridX is using. I do this by using grid.setStore() and pass in a Dojo JsonStore (this is asynchronous data of course). I do not recreate the grid every time I change the data store, just call setStore(), then refresh().

The grid also has the NestedSort module activated. My problem is this:

If the user sorts on a store, and then chooses a set of different data to look at, the code calls:

grid.sort.clear();
grid.setStore( /* new store*/ );
grid.refresh();

Without .clear() being called, the grid will try to sort the new store of data (which is usually invalid, and throws a 500).

With .clear(), the store will make a call to the server to sort the first data store, before then calling for a fresh batch of the next data store.

Ideally I want to tell the grid to clear any sort preference before I grab the next set of data, so that it is not attempting to sort it. I do not want it to make an additional call to sort the first data immediately before it gets replaced.

Upvotes: 0

Views: 139

Answers (1)

Andrew Daniel
Andrew Daniel

Reputation: 718

I finally worked it out. To clear the sort information in the grid you must modify the grid model. The sorting in the grid model can be done using this:

grid.model.sort();

Upvotes: 0

Related Questions