0

I am using ExtJs 4.1. My application is having two grid. Both the grid have grouping feature (I am using two unique Grouping feature). Both the grids are using single store. Each grid is having two button used to enable and disable the grouping feature. All this is working fine.

Problem: When I disable grouping feature in one grid and open second grid, the grouping feature in second grid also gets disabled even though the grids & grouping features are different. I am not sure what is the reason for this behavior.

Please use this fiddle to reproduce the issue and see the code.

Use fiddle to see the code

Thanks !!!1

SharpCoder
  • 18,279
  • 43
  • 153
  • 249

1 Answers1

4

This would work... http://jsfiddle.net/WRTM3/1/

Ext.define('myKindOfStore');
var store1 = Ext.create('myKindOfStore');
var store2 = Ext.create('myKindOfStore');

It seems that the grouping feature is actually executed on the store behind the grid. Since you use the same store in both grids each grouping plugin act like two different light switches controling the same bulb...

If you want to seperate grids behaviour, just define a new store and create two seperate store instances for each grid (see my jsfiddle fork)

This way all operations on grid1=store1 have no effects on grid2=store2 including filtering, sorting, etc.

Hope this is what you wanted :-)

Thomas
  • 198
  • 1
  • 8
  • Thank you for the reply. But I do not understand when you clear the grouping for a grid and then close the main window & then open the grid again, why the grouping feature is disabled? When I close the window, I am assume, the grid is also destroyed along with group feature. Now when I open the window (which load the grid) the grid should have the grouping feature enabled. – SharpCoder Nov 20 '13 at 13:00
  • First of all there is a difference between closing and destroying a window. Only the latter will make the relevant settings "forgotten". In your example, though, you're defining/creating a store. At no point is that store destroyed (you can't close a store - at least not in programming :-). In your grids you are *referencing* the store. And when you activate grouping, that command is passed on to the referenced store. Check out this: http://jsfiddle.net/W4UR5/ It's your code with windows not modal. Open both side by side and change grouping on either one > the other one will change too – Thomas Nov 20 '13 at 14:35
  • Look at it this way: The grid view only acts as a control interface for the store behind it. If click on a column header for sorting, the grid tells the store: "Sort by column X", then the store returns all the data in the sorted order and the grid updates its content. But a store can be used by many views at the same time. They will all be updated (filter, sort, group) when the store is changed - regardless of which view triggered the change. – Thomas Nov 20 '13 at 14:39