PDA

View Full Version : the



m4eclipse
2 Oct 2010, 5:20 PM
http://docs.sencha.com/designer/Designer-Getting-Started.pdf (http://docs.sencha.com/designer/Designer-Getting-Started.pdf%20%20I%20follow%20this%20document,%20after%20all%20the%20steps,%20I%20try%20to%20see%20the%20source%20codes%20generated%20by%20ext%20designer,however%20I%20was%20suprised%20to%20the%20object%20defination%20and%20creation.%20%20%20Take%20the%20CarStore.js%20for%20example,%20I%20just%20find%20the%20codes%20to%20define%20a%20Jsonstore:%20CarStore%20=%20Ext.extend%28Ext.data.JsonStore,%20%7B%20%20%20%20%20constructor:%20function%28cfg%29%20%7B%20..........%20%7D%29;%20new%20CarStore%28%29;%20%20However%20when%20this%20store%20is%20used:%20%20%20%20%20%20%20%20%20this.items%20=%20[%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20xtype:%20%27editorgrid%27,%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20store:%20%27CarStore%27,%20............................%20%20%20%20%20%20%20%20%20%20%20%20%20%7D,%20I%20wonder%20the%20store%20property,%20is%20a%20instance%20of%20CareStore%20has%20been%20built?%20Where?%20%20Because%20I%20used%20to%20use%20the%20store%20by%20the%20follwing%20way:%20%20var%20myStore=new%20Ext.data.JsonStore%28%7B......%7D%29;%20%20var%20p=new%20Ext.grid.GridPanel%28%7B%20%09store:myStore%20%09......%20%7D%29;%20%20So%20I%20can%20not%20understand%20the%20usage%20of%20the%20Ext%20designer.)

I follow this document, after all the steps, I try to see the source codes generated by ext designer,however I was suprised to the object defination and creation.


Take the CarStore.js for example, I just find the codes to define a Jsonstore:

CarStore = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
..........
});
new CarStore();

However when this store is used:

this.items = [
{
xtype: 'editorgrid',
store: 'CarStore',
............................
},
I wonder the store property, its value is a class name rather than a object instance,that's to say is a instance of CareStore has been built? Where?

Because I used to use the store by the follwing way:


var myStore=new Ext.data.JsonStore({......});

var p=new Ext.grid.GridPanel({
store:myStore
......
});

So I can not understand the usage of the Ext designer.

jarrednicholls
3 Oct 2010, 6:15 PM
Hi m4eclipse,

The string represents the configured "storeId" that's assigned to the JsonStore. This has been a part of Ext JS for, well, years. The "storeId" is registered into the Ext.StoreMgr when the instance of the Store is created. You can then call Ext.StoreMgr.lookup('MyStoreId'); to retrieve the instance of the store, no matter where it was originally instantiated. Data-bound widgets such as the GridPanel use the "store" configuration to lookup the store in the Ext.StoreMgr. You can still pass an instance of a store directly, but the Designer uses the storeId approach.

Hope that helps.