PDA

View Full Version : [FIXED-129] Store sorting direction



tfrugia
13 Jul 2010, 8:48 PM
When calling store.sort(), direction is ignored. Example:



var dsEvents = new Ext.data.Store({
autoLoad: true,
model: 'ministryEvents',
storeId: 'mystoreEvents',
proxy: {
url: 'index.cfm?action=general.getMinistryEvents&ministryID=' + ministryID,
type: 'ajax',
reader: {
type: 'json',
root: 'RESPONSE.DATA'
}
}
});

dsEvents.load({
callback: function(){
dsEvents.sort("EVENTDATE", "DESC");
}
});


This will sort ASC, unless we supply defaultSortDirection in the store's constructor as DESC per:




// the passed "direction" parameter is never used
sort: function(sorters, direction, suppressEvent) {

sorters = sorters || this.sorters;

direction = (this.sortToggle[name] || this.defaultSortDirection).toggle('ASC', 'DESC');
...


Unless I am missing something painfully obvious, this is a bug. I would also suggest adding a sortInfo parameter to the store like ExtJS so we do not have to worry about sorting the store after it's loaded.

SimonFlack
19 Jul 2010, 1:06 AM
I am also experiencing sort direction issues. Everytime I load data into a store the direction toggles between ASC and DESC no matter what I set.

edspencer
3 Sep 2010, 7:25 PM
Thanks for the report. Store sorting behavior has now been updated to better reflect the current Ext JS 3.x approach, meaning that this:



store.sort('myField');
store.sort('myField');


Is now equivalent to:



store.sort('myField', 'ASC');
store.sort('myField', 'DESC');


When passing a single argument to sort like we do above, toggling of direction is handled internally per field by the Store. These changes will be present in the next release.