Results 1 to 7 of 7

Thread: "Cannot call method 'getProxy' of undefined" when defining a Ext.data.Store

  1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    139

    Default "Cannot call method 'getProxy' of undefined" when defining a Ext.data.Store

    Hello

    I'm trying to setup a basic application using MVC. The app works fine with models, controllers and views. But when I define a Store I get

    Code:
    Uncaught TypeError: Cannot call method 'getProxy' of undefined
    Below is the code of the main applications:

    Code:
    Ext.Loader.setConfig({ enabled: true });
    
    Ext.application({
        name: 'Data', 
        controllers: ['People'],
        initialize: function () {
            console.log('app initialize');
            this.callParent();
        },
    
    
        launch: function() {
            console.log('launch') ;
        }
    }) ;
    This file is stored in app/

    Next, in app/controller I have a file People.js
    Code:
    Ext.define('Data.controller.People', {   
        extend: 'Ext.app.Controller',
        models: ['User'],
        stores: ['users'],
        
        init: function() {
        },
        onLaunch: function() {
        }
    });
    and the model at app/model/User.js
    Code:
    Ext.define('Data.model.User', {    extend: 'Ext.data.Model',
        alias: 'model.usr',
        fields: [
            {name: 'firstName',  type: 'string'},
            {name: 'lastName',  type: 'string'}
        ]
    });
    });
    and finally in app/store/users.js
    Code:
    Ext.create('Ext.data.Store', {
        model: 'User',
        data: [
            { firstName: 'Ed',    lastName: 'Spencer' },
            { firstName: 'Tommy', lastName: 'Maintz' },
            { firstName: 'Aaron', lastName: 'Conran' },
            { firstName: 'Jamie', lastName: 'Avins' }
        ]
    });
    I can see that all files are loaded, so I guess the naming is correct. I also tried to add a proxy to the store

    Code:
    Ext.create('Ext.data.Store', {    model: 'User',
        data: [
            { firstName: 'Ed',    lastName: 'Spencer' },
            { firstName: 'Tommy', lastName: 'Maintz' },
            { firstName: 'Aaron', lastName: 'Conran' },
            { firstName: 'Jamie', lastName: 'Avins' }
        ],
    
    
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
            }
        }
    });
    but then the error I get changes to

    Code:
    Uncaught TypeError: Cannot read property 'prototype' of undefined
    Any suggestions ?

    Cheers
    Luca

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    If you are specifying classes in the stores config of a controller, it expects a class with the name, not just the Ext.create. So you need to use Ext.define to create a new store class like you did for your controller and model.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Jun 2010
    Posts
    139

    Default

    thanks a lot for the quick reply!
    I changed my store to

    Code:
    Ext.define('Ext.data.Store', {    
         model: 'User',
        storeId:'users',
        data: [
            { firstName: 'Ed',    lastName: 'Spencer' },
            { firstName: 'Tommy', lastName: 'Maintz' },
            { firstName: 'Aaron', lastName: 'Conran' },
            { firstName: 'Jamie', lastName: 'Avins' }
        ],
    
    
        proxy: {
            type: 'memory',
            reader: {
                type: 'json',
            }
        }
    });
    Now when I run the application it remains blank nothing in the console
    For example, I'm using the storeId in the controller, is this correct ?
    Do you have other suggestions ?

    thanks a lot

  4. #4
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    You extend Ext.data.Store and your class name should be Data.store.users (note that users should really be capitalized, you would need to change this in the controller as well)
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  5. #5
    Sencha User
    Join Date
    Jun 2010
    Posts
    139

    Default

    thats it, thanks a lot!!

    I really like Sencha Touch, but the errors (or blank screen) are very hard to debug!

    cheers

  6. #6
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,449

    Default

    What JS file are you using? sencha-touch-debug.js should give you some errors and call stacks that help you plus the understanding of the MVC pattern will be better as the next release there will be more tutorials.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Fullstack Engineer
    ________________
    Modus Create is based on the model of an open source team. We’re a remote, global team of experts in our field. To find out more about the work we do, head over to our website.

    Check out my GitHub:
    https://github.com/mitchellsimoens

  7. #7
    Sencha User
    Join Date
    Jun 2010
    Posts
    139

    Default

    ok, I'm using sencha-touch-all-uncompressed-w-comments.js
    Thnx for the tip!

Posting Permissions

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