View Full Version : Define a DESC grouper for a store

1 Sep 2011, 2:03 AM
I try to define a desc grouper for my store like this :

Ext.define('FDM.store.Parts', {
extend: 'Ext.data.Store',
model: 'FDM.model.Part',
groupers:[{direction:'DESC', property:'type'}],

But it doesn't work.
After looking in the Store.js source file, I understand why.
In the decodeGroupers function, if the grouper is not "instanceof" Grouper, it overwrite direction with 'ASC'.

decodeGroupers: function(groupers) {
if (!(config instanceof Grouper)) {
Ext.applyIf(config, {
root : 'data',
direction: "ASC"

Why overwrite the value if this one exist ?

To solve my problem, I extend the constructor method like this :

constructor: function(config) {
config = Ext.apply({}, config);
config.groupers = [new Ext.util.Grouper({direction:'DESC', property:'type'})];


1 Sep 2011, 3:33 PM
What do you mean by 'it doesn't work'? What happens?

I don't believe the line you've identified is the cause of your problem. Ext.applyIf() will not overwrite existing properties (unlike Ext.apply(), which will). You should be able to confirm this by putting breakpoints in just before and after that line.