简体   繁体   中英

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.

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();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM