PDA

View Full Version : Multiple View using same Store to display different data



vinothsencha
27 Nov 2013, 2:59 AM
I am having 2 windows in my project. Both are having grid panel with same set of columns.
I need to display different data in both the windows.


I am creating a JSON store (via project inspector) and assigning it to the grid in both the windows by using 'store' config.
I have opened both the windows.
On clicking a button in first window, i am loading a set of records.
var datastore = win.down('#firstgriditemid').getStore();
datastore.loadData(jsondata);


But the same data is loading automatically in second window grid also.
I know that this is happening because we are assigning a same store to both the grid panel window.


But in my scenario, i should not load data automatically in other windows.
What i need to do to achieve this without creating multiple stores?


How to make use of same store to display 2 different set of data?


Thanks in advance.

Misiu
27 Nov 2013, 4:11 AM
Please teka a look at my fiddle: https://fiddle.sencha.com/#fiddle/v1 this might help You :)

vinothsencha
27 Nov 2013, 5:00 AM
Thanks for the reply Misiu..

You are having 2 stores.
But how this can be done without creating multiple stores?

How to make use of same store to display 2 different set of data?

stevenbrent
27 Nov 2013, 11:35 AM
In your grid configuration, you use the columns config 'dataIndex' property to specify which fields from each record should be displayed. See: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.grid.column.Column

So you can share the same store between two grids, but display different sets of data from that store in each grid.

It may be that I am not quite getting what your requirement is -- are you trying to display different fields from the same data set in each grid? Or are these totally separate data sets?

vinothsencha
28 Nov 2013, 12:08 AM
Thanks steve...

Fields are same in both the grid.. should use same json store.
But the data content will vary in both the grid..

How to make use of same store to display in both the places?