Created
September 11, 2012 09:22
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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