Skip to content

Instantly share code, notes, and snippets.

@JohanVandeplas
Created September 11, 2012 09:22
Show Gist options
  • Save JohanVandeplas/3697157 to your computer and use it in GitHub Desktop.
Save JohanVandeplas/3697157 to your computer and use it in GitHub Desktop.
fix mapping for sorting (+ extra sorting param for special sorter mapping) Works for normal and simpleSortMode
Ext.override(Ext.data.proxy.Server, {
encodeSorters: function (sorters, string) {
var model = this.model,
map = model.prototype.fields.map,
encSort = Ext.Array.map(sorters, function (sorter) {
return {
property : map[sorter.property].sorting || map[sorter.property].mapping || sorter.property,
direction: sorter.direction
};
});
if(string===false){
return encSort;
} else {
return Ext.encode(encSort);
}
},
getParams: function(operation) {
var me = this;
params = me.callParent([operation]);
sorters = operation.sorters,
simpleSortMode = me.simpleSortMode,
sortParam = me.sortParam,
directionParam = me.directionParam;
if (sortParam && sorters && sorters.length > 0) {
if (simpleSortMode) {
var encSort = me.encodeSorters(sorters, false);
params[sortParam] = encSort[0].property;
params[directionParam] = encSort[0].direction;
}
}
return params;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment