View Full Version : Making new instance of a Store
seawade
20 Feb 2012, 4:26 PM
Dear All,
I'm not sure if I should post this question here or ExtJS4 forum, if this is not the place please let me know.. I am trying to create simple form panel using designer, and trying to -create- new store from store definition for treepanel (store def already made from designer) each time I create the form.
From designer I can select the store for treepanel and all working however I am not sure how I can tell designer to create new store (instance) each time since I can't modify implementation class. As you can see, I'm new to ExtJS, Javascript, MVC.
Where would I say something like..
var store = Ext.create('somestore').. OR how do I use designer so that it will be effectively like:
xtype: 'treepanel',
itemId: 'CategoryTree',
collapsed: false,
store: Ext.create('somestore'), (instead of 'somestore')
viewConfig: {
rootVisible: false
},
If I change from store property of designer, it comes as store: 'Ext.create(\'somestore\')', instead..
I'm trying to do all this just using designer 2.0 without hand modifying the source codes (which.. designer 2.0 overwrites).. if at all possible.
Would I be doing such thing using controllers? or events?
Thank you!
seawade
21 Feb 2012, 5:20 AM
I somehow to got using controller...
I think it will better describe what I'm trying to do.
if(tab) {
console.log('found!');
tab.show();
} else {
console.log('not found!');
var product = Ext.create('Sample.view.ProductForm', {
title: tabName,
closable: true
});
var test = product.down('treepanel > dataview');
var store = Ext.create('Sample.store.StoresCategories');
console.log(test);
console.log(store);
test.bindStore(store);
tab = panel.add(product);
product.show();
}
ProductForm is a tabpanel which has form and inside of this form there is treepanel for selecting categories. There is also StoresCategories defined but I want to create new instance of store (as oppose to one I selected from designer as config value). Because whenever I am clicking a treenode, other treepanel reacts to click action instead of one that is clicked. I am guessing it's because of using same store...
Any pointers will be very appreciated!
seawade
21 Feb 2012, 7:54 AM
While I am trying everything I could try, I found just creating new store instance by
var whateverstore = Ext.create('Sample.store.StoresCategories');
just before I create the form (with tree), seems like making it to use newly created store. (without adding whateverstore anywhere). Now clicking the node does not affect other treepanel that's using SotresCategories.
var whateverstore = Ext.create('Sample.store.StoresCategories');
var product = Ext.create('Sample.view.ProductForm', {
title: tabName,
closable: true
});
I have no idea but seems like Form (with tree) is using -last- created instance of StoresCategories?
I can work with this but is this right way of using it or will it continuously make stores until memory fills up as I use the application and make and destroy forms?
Thanks!
aconran
21 Feb 2012, 6:37 PM
You've raised a lot of good points here that we are discussing internally before giving you response.
Just want to make sure you don't feel neglected ;)
mehran
28 Apr 2012, 6:31 AM
As a user who follows this thread, it's been more than a month since the last post on this thread whilst both Sencha Architect and ExtJS have gone under major releases (Sencha Architect 2 and ExtJS 4.1 are out now) and I wonder if this issue has been addressed in any of the releases.
I've had the same problem with Sencha Architect for a while now. It doesn't support inline stores. One can not instantiate a new store for a component which means using global stores are mandatory. As for the grids it's possible to replace their store later (programmatically) using "reconfigure" method but trees do not have such a method! And thus it's a deadlock.
Please let us know if any solution is made available.
Regards,
MaciejZabielski
29 Sep 2012, 1:47 PM
Well, I guess we are neglected here with this problem. I'm prototyping ExtJS application (4.1 + Architect 2).
We will most likely not use Architect at all, but now, it looked like a good idea to keep app organized as Architect wants it just to make it right MVC.
I have the same situation, where I want to add several tree panels to the same application view. Each works the same way, so they could use the same controller with view context. But each is using different data, that might contain the same objects arranged in different way. Since we would have one controller instance, I would have to create Store instance in each view instance. In Architect I can only select store from class list. There is no way to add store creation to initComponent (or I can't see how) and I guess that is very good place to do that.
Second option would be to add Ext.create to "store"?
Not everybody lives in a perfect world, where we have one simple view with one "products" list and static layout :)
I too like to have { store: Ext.create() } available in Architect
aconran
28 Jan 2013, 12:51 PM
It's on the list of thigns to look at but hasnt gotten the attention it needs.
We will look at it after the 2.2 release.
boonkerz
28 Jan 2013, 1:55 PM
var row = panel.items.getByKey('myshipping' + record.raw.id);
if(row) {
}else{
this.getMyTabPanel().add({
closable: true,
xtype: "MyShipping",
id: 'myshipping' + record.raw.id,
title: record.raw.shopTitle + ' - Versandart'
}).show();
Ext.getCmp('myshipping' + record.raw.id).reconfigure(Ext.create('MyApp.store.MyShippingStore'));
Ext.getCmp('myshipping' + record.raw.id).store.proxy.extraParams.shopId = record.raw.shop;
Ext.getCmp('myshipping' + record.raw.id).store.load();
}
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.