1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    39
    Answers
    1
    Vote Rating
    4
    MattUCG is on a distinguished road

      0  

    Default Answered: Ext.data.Store: create vs. define

    Answered: Ext.data.Store: create vs. define


    In the documentation examples I've seen, stores are defined using Ext.create, but in the demo apps like KitchenSink (e.g. kitchensink\app\store\Demos.js), i see the Ext.define syntax. Are both valid? I can't seem to get the define command to work.

    This works:

    Code:
    Ext.create('Ext.data.Store', {
        id: 'ContentItems',
    
    
        autoLoad: true,
        fields: ['name'],
        data: [
            { name: 'Cowper' },
            { name: 'Everett' },
            { name: 'University' },
            { name: 'Forest' }
        ],      
    
    
    });
    
    
    Ext.application({
        name: 'TestApp',
    
    
        requires: ['Ext.List', 'Ext.data.Store'],
    
    
        launch: function () {
            alert('launch - app');
            Ext.Viewport.add(Ext.create('Ext.List', {
                store: 'ContentItems',
    
    
                itemTpl: '{name}'
            }));
        }
    });
    This does not:

    Code:
    Ext.define('TestApp.store.ContentItems', {
        extend: 'Ext.data.Store',
        id: 'ContentItems',
        config: {
            autoLoad: true,
            fields: ['name'],
            data: [
                { name: 'Cowper' },
                { name: 'Everett' },
                { name: 'University' },
                { name: 'Forest' }
            ],       
        }
    });
    
    
    Ext.application({
        name: 'TestApp',
    
    
        requires: ['Ext.List', 'Ext.data.Store'],
    
    
        launch: function () {
            alert('launch - app');
            Ext.Viewport.add(Ext.create('Ext.List', {
                store: 'ContentItems',
    
    
                itemTpl: '{name}'
            }));
        }
    });

  2. When you use MVC to define your stores, you need to also include your store in your application definition.

    Code:
    Ext.application({
        name: 'MyApp',
    
        stores: ['ContentItems']
    });
    You also do not need to specify an 'id' inside your store configuration.

  3. #2
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    When you use MVC to define your stores, you need to also include your store in your application definition.

    Code:
    Ext.application({
        name: 'MyApp',
    
        stores: ['ContentItems']
    });
    You also do not need to specify an 'id' inside your store configuration.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    39
    Answers
    1
    Vote Rating
    4
    MattUCG is on a distinguished road

      0  

    Default


    Thanks for the help

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi