2
votes

I currently have a grid with a grouping feature that gets data from a fixed store:

Ext.define('YUK.store.FakePendingDocs', {
    extend: 'Ext.data.Store',
    id: 'FakePendingDocs',
    autoSync: false,
    proxy: {
        type: 'memory'
    },

   fields: [ { name: 'docId', mapping: 'did' }
            , { name: 'name', mapping: 'name'}//, mapping : 'name'}
            , { name: 'client',mapping: 'cid' }
            , { name: 'description', mapping: 'description' }
            , { name: 'uploadeddate', mapping: 'dl', type: 'date', dateFormat: 'MS' }
            , { name: 'folder', mapping: 'fo' }
            , { name: 'group', mapping: 'gr' }

           ],

   groupers: [{
       property: 'group',
       direction: 'ASC'
   }],. 

   data: [ ... ]



}
);

Then i do in my grid:

Ext.define('YUK.view.center.pendingdocuments.Panel', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.documents',
    id: 'documents',
    title: 'My Documents',
    store: 'FakePendingDocs',

    hideHeaders: true,
    forceFit: true,

    groupField: 'group',

....

But i have the problem that my selection is scrambled in my grid (i select an item and i get another one). I found this http://www.sencha.com/forum/showthread.php?208453 thread to solve this. But since i'm new to sencha i don't know how to override this. I have done things like :

Ext.define('YUK.store.FakePendingDocs', {
    extend: 'Ext.data.Store',
    id: 'FakePendingDocs',
    autoSync: false,
    proxy: {
        type: 'memory'
    },

   fields: [ { name: 'docId', mapping: 'did' }
            , { name: 'name', mapping: 'name'}//, mapping : 'name'}
            , { name: 'client',mapping: 'cid' }
            , { name: 'description', mapping: 'description' }
            , { name: 'uploadeddate', mapping: 'dl', type: 'date', dateFormat: 'MS' }
            , { name: 'folder', mapping: 'fo' }
            , { name: 'group', mapping: 'gr' }

           ],

   groupers: [{
       property: 'group',
       direction: 'ASC'
   }],. 

   data: [ ... ],

   sort:function(){
     var me = this, groups, g;




     me.callOverridden(arguments);
     groups = me.getGroups();


     me.data.clear();


     Ext.Array.each(groups, function (group) {
        Ext.Array.each(group.children, function (child) {
           me.data.add(child.internalId, child);
        });
     });
     me.fireGroupChange();
  }

}
);

But this doesn't work , neither does putting it in the grid.

Can someone help me with this ?

P.S: my groupingfeature for the grid looks like this:

var groupingFeature = Ext.create('Ext.grid.feature.Grouping', {
    groupHeaderTpl: '{name}'


});

Thread on Sencha Forums

3
Which version of ExtJS do you use? I can't reproduce problem in 4.0.7.Krzysztof

3 Answers

3
votes

There seemed to be no answer working for my problem.

Therefor i resolved it by using a dataview

2
votes

I am not sure but Panel does not have option like groupField but Store has. So maybe you should move groupField: 'group', from panel to store.

UPDATE: So thats Extjs bug. Someone provided fix for this dont know if it is working but try to add:

Ext.override(Ext.data.Store, {
  sort:function(){
     var me = this, groups, g;

     me.callOverridden(arguments);
     groups = me.getGroups();

     me.data.clear();

     Ext.Array.each(groups, function (group) {
        Ext.Array.each(group.children, function (child) {
           me.data.add(child.internalId, child);
        });
     });
     me.fireGroupChange();
  }
});

somewhere before your store or on application launch or where you think it is right place

0
votes

I answered to similar question in Sencha Forum

I was having the same issue and the following did the trick: I added this sorters in my store:

sorters: [{
    property: 'category',
    direction: 'ASC'
}]

Note the 'category' is the column I used for grouping as groupField in my store. Sorting with the groupField column is NEEDED, otherwise grid selection will work not properly.