Results 1 to 3 of 3

Thread: getStore Problem

  1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    3

    Default getStore Problem

    Hey,

    I tried to create a new application with the sencha touch command and sdk that worked pretty nice. My next step was to create a very simple application but it is not possible for me to call Ext.getStore('storeId'). I think it is just a small mistake of me but it drives me crazy :P
    Here is my code

    app.js
    Code:
    //<debug>Ext.Loader.setPath({
        'Ext': 'touch/src',
        'PerformancePrototype': 'app'
    });
    //</debug>
    
    
    Ext.application({
        name: 'PerformancePrototype',
    
    
        requires: [
            'Ext.MessageBox'
        ],
    
    
        views: ['Main'],
        models: ['PerformancePrototype.model.User'],
        stores: ['PerformancePrototype.store.Users']
    
    
        icon: {
            '57': 'resources/icons/Icon.png',
            '72': 'resources/icons/Icon~ipad.png',
            '114': 'resources/icons/[email protected]',
            '144': 'resources/icons/[email protected]'
        },
    
    
        isIconPrecomposed: true,
    
    
        startupImage: {
            '320x460': 'resources/startup/320x460.jpg',
            '640x920': 'resources/startup/640x920.png',
            '768x1004': 'resources/startup/768x1004.png',
            '748x1024': 'resources/startup/748x1024.png',
            '1536x2008': 'resources/startup/1536x2008.png',
            '1496x2048': 'resources/startup/1496x2048.png'
        },
    
    
        launch: function() {
            // Destroy the #appLoadingIndicator element
            Ext.fly('appLoadingIndicator').destroy();
    
    
            // Initialize the main view
            Ext.Viewport.add(Ext.create('PerformancePrototype.view.Main'));
        },
    
    
        onUpdated: function() {
            Ext.Msg.confirm(
                "Application Update",
                "This application has just successfully been updated to the latest version. Reload now?",
                function(buttonId) {
                    if (buttonId === 'yes') {
                        window.location.reload();
                    }
                }
            );
        }
    });
    My Main view looks so
    Code:
    Ext.define('PerformancePrototype.view.Main', {    extend: 'Ext.form.Panel',
        xtype: 'main',
        requires: [
            'Ext.data.Store'
        ],
        config : {
                fullscreen : true,
                id : 'register',
                items : [{
                            xtype : 'textfield',
                            name : 'name',
                            label : 'Name'
                        }, {
                            xtype : 'emailfield',
                            name : 'email',
                            label : 'Email'
                        }, {
                            xtype : 'button',
                            text : 'Test Local',
                            handler : function(button) {
                                var test = Ext.getStore('userStore');
                                console.log(test);
                            }
                        }]
            }
        });
    My store looks so
    Code:
    Ext.define('PerformancePrototype.store.Users', {     extend: 'Ext.data.Store',
        requires : [ 'PerformancePrototype.model.User' ],
        config : {
            storeId : 'userStore',
            model : 'PerformancePrototype.model.User'
        }
        proxy: {
            type: 'ajax',
            url : '/users.json',
            reader: {
                type: 'json',
                rootProperty: 'users'
                }
            },
        autoLoad: true
    });
    and finally my model
    Code:
    Ext.define('PerformancePrototype.model.User', {    extend: 'Ext.data.Model',
        config: {
            fields: [
                {name: 'firstName', type: 'string'},
                {name: 'lastName',  type: 'string'},
                {name: 'age',       type: 'int'},
                {name: 'eyeColor',  type: 'string'}
            ]
        }
    });
    The error that i get is that the store is undefined.

  2. #2
    Sencha Premium User mrsunshine's Avatar
    Join Date
    Sep 2008
    Location
    Germany - Darmstadt
    Posts
    693
    Answers
    21

    Default

    proxy definition has to be in the config object of the store

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    3

    Default

    Hey thanks for your reply. I put the proxy in the config of the store but i i get now an error that The following classes are not declared even if their files have been loaded: 'PerformancePrototype.store.Users'. Please check the source code of their corresponding files for possible typos: 'app/store/Users.jssencha-touch.js:8326

    I am not sure why i get this error because in my app.js i declare the store, model and view. And just the store gives me the error.

    Here is how i declared the store
    Code:
    Ext.define('PerformancePrototype.store.Users', { 
    	extend: 'Ext.data.Store',
    	requires : [ 'PerformancePrototype.model.User' ],
        config : {
            storeId : 'userStore',
            model : 'PerformancePrototype.model.User'
        
        proxy: {
            type: 'ajax',
            url : '/users.json',
            reader: {
                type: 'json',
                rootProperty: 'users'
            	}
        	},
        
        }
    });

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •