PDA

View Full Version : Adding group feature to rendered grid panel?



mx_starter
31 Jan 2013, 9:56 AM
Hi, is it possible a grid panel "to be grouped" after it has been rendered and how to accomplish that?

Initially - the grid store has no groupField assigned and the grid is rendered.

Later on, i want to add a groupField to the store and the grid to reflect the changes (showing data in groups):

for example:

...
//group the store
Ext.data.StoreManager.lookup('gridStore').groupField = 'grpFld';
Ext.data.StoreManager.lookup('gridStore').group('grpFld');

//add the grouping feature to the grid
Ext.apply( Ext.getCmp('gridPanel'), { features: [Ext.create('Ext.grid.feature.Grouping')] } );

//is that needed?
Ext.getCmp('gridPanel').reconfigure( Ext.data.StoreManager.lookup('gridStore') );
Ext.getCmp('gridPanel').getView().refresh();

...

The code above groups the store, so:

console.log( Ext.data.StoreManager.lookup('gridStore').isGrouped() );
reports 'true'.



console.log( Ext.getCmp('gridPanel').features );

reports array with the appropriate object within.

However, the grid panel is still ungrouped.
If i add the grouping feature definition upon creating the grid component - then all is fine.

So - what needs to be done with the grid panel / grid view after store is grouped and features array of the grid panel is given the grouping feature object?

mitchellsimoens
4 Feb 2013, 9:30 AM
Why not add in the group to the store at all times and then let the view enable/disable grouping?

mx_starter
4 Feb 2013, 1:34 PM
Why not add in the group to the store at all times and then let the view enable/disable grouping?

If fact, that was i finished with... Well, almost...
I added the feature upon grid definition, and then grouped the store dynamically.
Just was interested if it is possible the features array of the grid to be dynamically populated reflecting the grid view automatically.