0

So the issue is that if you instantiate a store with

remoteSort

and

groupField

the store triggers a request to the server behaving in an auto-load way.

e.g

Ext.create('Ext.data.Store',{
  remoteSort: true,
  groupField: 'someProperty',
  model: 'MyApp.model.SomeModel',
  proxy: {
    type: 'ajax',
    api: {
      read: 'myRestUrl'
    },
    reader: {
      type: 'json',
      rootProperty: 'data'
    }
  }
});

The above triggers a request to

myRestUrl

and it should not.

Using ExtJs 6.02

code4jhon
  • 5,725
  • 9
  • 40
  • 60
  • Please report over [at Sencha Official Forum, in the ExtJS 6 Bugs section](https://www.sencha.com/forum/forumdisplay.php?134-Ext-6-Bugs). – Alexander Jun 13 '16 at 16:14
  • Thanks for the suggestion but I think this is a wider platform and also more active. I would love if Sencha had their own implementation like Unity and some others http://answers.unity3d.com/questions/ – code4jhon Jun 13 '16 at 17:39
  • 1
    That wider audience doesn't fix ExtJS bugs, only Sencha can do that. Nuff' said. – Alexander Jun 13 '16 at 18:27
  • No worries almost solved the issue. – code4jhon Jun 13 '16 at 19:02

1 Answers1

0

So to avoid having a store with

remoteSort: true

and

groupField

to be auto loaded, I overrode group method on 'Ext.data.AbstractStore'

/**
 * Groups data inside the store.
 * @param {String/Object} grouper Either a string name of one of the fields in this Store's
 * configured {@link Ext.data.Model Model}, or an object, or a {@link Ext.util.Grouper grouper} configuration object.
 * @param {String} [direction] The overall direction to group the data by. Defaults to the value of {@link #groupDir}.
 */
group: function(grouper, direction) {
    var me = this,
        sorters = me.getSorters(false),
        change = grouper || (sorters && sorters.length)

    if (grouper && typeof grouper === 'string') {
        grouper = {
            property: grouper,
            direction: direction || me.getGroupDir()
        };
    }

    me.settingGroups = true;
    me.getData().setGrouper(grouper);
    delete me.settingGroups;

    if (change) {
        if (me.getRemoteSort()) {
            /**
             * when grouping a store only if the store is loaded trigger a load otherwise
             * the store would be autoloading.
             */
            if(me.isLoaded()) {
                me.load({
                  scope: me,
                  callback: me.fireGroupChange
                });
            }
        } else {
            me.fireEvent('datachanged', me);
            me.fireEvent('refresh', me);
            me.fireGroupChange();
        }
    }
    // groupchange event must fire when group is cleared. 
    // The Grouping feature forces a view refresh when changed to a null grouper 
    else {
        me.fireGroupChange();
    }
},

});

code4jhon
  • 5,725
  • 9
  • 40
  • 60