-
10 Dec 2011 9:22 PM #1
Answered: preferred way to make a store
Answered: preferred way to make a store
I have this model:
And this two ways to declare a store, the first one throws an error saying I'm trying to define a store with no model, the second works ok but can't get to it on the safari debugger, what's the difference between the two and which one should I use?Code:Ext.define('Article',{ extend: 'Ext.data.Model', fields: [ {name:'Headline',type:'string'}, {name:'Summary',type:'string'}, {name:'Body',type:'string'}, {name:'Thumbs',type:'string',mapping:'Photos > Thumbnail'} ] });
Code:Ext.define('Articles_store',{ extend: 'Ext.data.Store', model: 'Article', proxy: { type: 'ajax', url: 'http://localhost:8080/data.xml', reader: { type: 'xml', root: 'channel', record: 'item' } }, autoLoad: true }) var Articles_store = Ext.create('Ext.data.Store',{ model: 'Article', proxy:{ type: 'ajax', url: 'http://localhost:8080/data.xml', reader: { type: 'xml', root: 'channel', record: 'item' } }, autoLoad: true });
-
Best Answer Posted by aacoro
I would use Ext.Define to define my own store. I think all classes in ExtJs4 and ST2 are created this way. With the Ext.create I would instantiate the classes that I created.
Check this post: http://www.sencha.com/forum/showthre...l=1#post595035
What I would do regarding your snippets:
1, Define my own namespace like MyApp:
and the Store:Code:Ext.define('MyApp.model.Article', {...});
And the I would instantiate the store like this:Code:Ext.define('MyApp.store.Article' , {...});
I hope you have read this: http://docs.sencha.com/touch/2-0/#!/guide/class_systemCode:Ext.create('MyApp.store.Article');
-
11 Dec 2011 3:06 AM #2
I would use Ext.Define to define my own store. I think all classes in ExtJs4 and ST2 are created this way. With the Ext.create I would instantiate the classes that I created.
Check this post: http://www.sencha.com/forum/showthre...l=1#post595035
What I would do regarding your snippets:
1, Define my own namespace like MyApp:
and the Store:Code:Ext.define('MyApp.model.Article', {...});
And the I would instantiate the store like this:Code:Ext.define('MyApp.store.Article' , {...});
I hope you have read this: http://docs.sencha.com/touch/2-0/#!/guide/class_systemCode:Ext.create('MyApp.store.Article');Last edited by aacoro; 11 Dec 2011 at 3:07 AM. Reason: typos
-
11 Dec 2011 9:06 AM #3
I see now, coming from sencha 1.1 I didn't have such a solid idea of using classes, any Idea of how would I be able to see the instantiated store on the safari debugger or firebug?
-
11 Dec 2011 9:09 AM #4
-
11 Dec 2011 10:19 AM #5
Yeah, I used to be able to add the stores to the "watch expression" list but I can't do it now in 2.0, I need it that way because I wanted to see it after it's loaded but I have to do some workarounds to get the info I need, I will keep looking anyway. thanks.


Reply With Quote
