View Full Version : [SOLVED] ExtJs 4.2 Multiple instances of the same Store

16 Apr 2014, 4:08 AM
Hi guys,

My situation is as follows, I'm trying to respect the DRY and reuse the code as much as possible (if it's still readable).
I have a grid that uses a store, and into another view I have a combo that need a read-only version of the data on the same store.

For example: Users/Groups, on the view to display the Users you have a combo to select a Group that should use the same Store as the view (grid) that displays the Groups. So far all filtering applied to the Groups store in the grid are visible in the combo to, because stores are singletons, is there an easy way to use a new instance of the same store ?

So far I tried to load it by hand and use something like this in the controller:

store: [App.store.Groups] to


initComponent : function() {
var me = this;

Ext.apply(me, {
store : me.buildStore()


buildStore : function() {
return Ext.create('App.store.Groups');

But all of my tests used the same store instance.

16 Apr 2014, 5:27 AM
Create new instance of store to each component i.e for grid and combo.
store: Ext.create('App.store.Groups');

If you want to use the filter to grid store only, then add this on grid render

render: function (grid){
grid.getStore().filterBy(function(record) { return record.get("name") == 'A';

16 Apr 2014, 6:11 AM
You could use the following:

Ext.define('App.store.MyStore', {
extend : 'Ext.data.Store',
alias : 'store.app-mystore', // create store alias

// ...

Ext.define('App.view.MyCombo', {
extend : 'Ext.form.field.ComboBox',
xtype : 'app-mycombo',

requires : [

// combo config

store : {
type : 'app-mystore' // store alias; type creates new instance

22 Apr 2014, 1:01 AM
Sorry for the late answer, this solve the problem.
I had to set the store.autoLoad to true otherwise the combo will not trigger it's load() method.

Thank you.