Requirement
Every time grid data is sorted - before the event is executed I want to change the store extraParams
with the values of new sort properties. Like If I am sorting a column Name in DESC direction - before the event is executed I want to overwrite extraParams
of store with dataIndex
of Name column and direction property DESC.
My store also has remoteSort
property set to true
.
I am using ExtJS 4.2.
Problem
I tried sortchange
event listener on grid but it is executed after the data API is called and records are loaded. What I would like to have is something like beforesortchange.
This all with remoteSort : true
.
Next problem is if i call this.getStore().load();
from sortchange
then my data api is called twice, which does not make sense.
Code
Grid listener:
sortchange: function(ct, column, direction, eOpts) {
this.getStore().getProxy().extraParams = {
'sort' : column.dataIndex,
'dir' : direction
}
// load() will call the data api again once the data loading is over
//this.getStore().load();
}
I tried following grid listeners also but either I dont get new grid sort parameters or they are not called at all:
beforeload
, beforesync
, beforeprefetch
, load
.