View Full Version : grid sort problem using sortchange event - ExtJS 4.1.1

24 Aug 2012, 5:58 AM
I have a problem with grid not sorting as expected when using sortchange event. When a grid header column is clicked, the grid header sort icon appears for a split second but the disappears when the load is complete. I'm thinking that the sortState is not getting set, but I'm not sure if I'm missing something. This is my store setup

Ext.define('EF.store.trade.Trade', {
extend: 'Ext.data.Store',
model: 'EF.model.trade.Trade',
autoLoad: false,
remoteSort: true,
remoteGroup: true,
pageSize: 60,
groupField: 'ExecutingMember',
proxy: {
type: 'ajax',
url: '/Trade/GetTrades',
actionMethods: 'Post',
extraParams: { loadSnapShot: 'N', itmFilter: '', ccFilter: '', priceFilter: '', productFilter: '', entityFilter: '', productExchFilter: '', productProd: '', productCntrct: '', login: '', grouper: 'ExecutingMember' },
reader: {
type: 'json',
root: 'list',
totalProperty: 'total'
sort: function (sorter) {
// **********************************************
// * DO NOT REMOVE!!!!!!! *
// * Keeps the sort from being submitted. *
// * Handled by the sortchange event!!! *
// * DO NOT REMOVE!!!!!!! *
// **********************************************
group: function (groupers, dir) {
this.fireEvent('group_grid', groupers);


I only need the sortchange event to fire as it has different params from the sort event.
I've run the debugger on this and it seems that the sortstate is always ASC and will only sort DESC if you select sort descending from the grid header menu, but even then the sort icons are missing..

24 Aug 2012, 8:49 PM
Is there are reason you are bypassing the default sort that is automatically sent to server?


On remoteSort, the server should process the sorted records.


29 Aug 2012, 4:29 AM
Thanks for you reply...

The database is HUGE, so I create snapshot of the data so that I can cut down on DB I/O. The snapshot is created when the store is initially loaded and params are used to let the backend process know whether to use the snapshot or create a new snapshot. The default store parameters are set to allow grid paging of the snapshot. When the grid header is clicked, the store parms needs to reflect that a new snapshot needs to be created. The sortchange event code was created to allow for different parms to be used and so force a new snapshot. The sort event was added without any logic otherwise the store is loaded twice, the store is loaded for the sort event and then loaded again for sortchange. Funny thing is that if I comment the dummy sort event, the sort icons work correctly, but with 2 store loads..

I've been messing with the code and Im trying to figure out how to change the store parms before the sort event gets fired. If I can figure this out, I can remove the sortchange event.