Threaded View

  1. #1
    Sencha User
    Join Date
    Dec 2011
    Location
    Bogota, Colombia
    Posts
    33
    Vote Rating
    0
    xyrer is on a distinguished road

      0  

    Question Answered: preferred way to make a store

    Answered: preferred way to make a store


    I have this model:

    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'}
    			]
    		});
    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('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
    		});

  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:
    Code:
    Ext.define('MyApp.model.Article', {...});
    and the Store:
    Code:
    Ext.define('MyApp.store.Article' , {...});
    And the I would instantiate the store like this:
    Code:
    Ext.create('MyApp.store.Article');
    I hope you have read this: http://docs.sencha.com/touch/2-0/#!/guide/class_system

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar