PDA

View Full Version : Multiview and single store



Cougar84
27 Apr 2012, 4:55 AM
Hi there,
I've a question about Stores & Views ...
I'm trying to make a big application with a lot of view and stores and controllers.

Here's my question:

I usually create a controller when a "program" is called.
This controller have n views and n store ...

I'm trying to open the same view twice ( for example ) and there is a grid inside connected with a store ...
thats the same because the view is the same ( but two instance ).

Now what happend ... if I made a search in a view and than go to the other i saw the same records ...

Thats because the store is the same ...

Now, how can I avoid this problem?
I mean ... it's my approach to the ExtJS system that is wrong for what i'm trying to do, or it's right and I have to change only something?

Thanks,
Marco

mitchellsimoens
1 May 2012, 7:13 AM
You will need to have two different stores for this.

Cougar84
1 May 2012, 11:48 PM
But How if the view is the same?????
That is my problem ...

Controller "Pippo"

Call View "Pluto" --> Store "Ciccio"
Recall another instance of the View "Pluto" --> Store "Ciccio"

How can I use two stores?
There are 2 instance of the same view ... but not of the Store ... The store is the same ...

vietits
1 May 2012, 11:56 PM
You could implement initComponent() method for your view class. In there, you will create a new instance of store for your view, not use the store loaded by controller. Example:


Ext.define('Your view class', {
...
initComponent: function(){
var me = this;
me.store = Ext.create('Your store class', {...});
me.callParent(arguments);
}
})

Cougar84
2 May 2012, 2:27 AM
Thats work ... but you loose the reference in the controller.

this.getBlaBlaBlaStore() ...

You have to put the ref by yourself on the component that use the store ...