简体   繁体   中英

Uncaught TypeError: Cannot read property 'getProxy' of undefined

I am getting "Cannot read property 'getProxy' of undefined" whenever a store is defined with Model as shown below.

Store:

Ext.define('AM.store.Users', {
extend: 'Ext.data.Store',
model: 'AM.model.User',
data: [
       { name: 'tommy', email: 'tommy@gmail.com ' },
       { name: 'gani', email: 'gani@gmail.com' }
]
}, function() {
  console.log('Store has loaded');
});

Model:

Ext.define('AM.model.User', {
 extends: 'Ext.data.Model',
 fields: ['name','email']
}, function() {
  console.log('Model has loaded');
});

Controller:

Ext.define('AM.controller.Users', {
    extend: 'Ext.app.Controller',       
    views: ['AM.view.user.List', 'AM.view.user.Edit'],
    stores: ['AM.store.Users'],
    models: ['AM.model.User'],
    init: function() {

        console.log('Controller class init called');

        this.control({
            'userlist' : { itemdblclick: this.editUser }                
        });
    },
    editUser: function(grid, record) {
        console.log('User edit has started ...');
        var view = Ext.widget('edituser');
        view.down('form').loadRecord(record);
    }
}, function() {
   console.log('Controller has loaded');
});

However things are working fine when an inline model is defined for Store as shown below.

Ext.define('AM.store.Users', {
  extend: 'Ext.data.Store',
  fields: ['name', 'email'],
  data: [
       { name: 'tommy', email: 'tommy@gmail.com ' },
       { name: 'gani', email: 'gani@gmail.com' }
]
}, function() {
  console.log('Store has loaded');
});

Not sure why error getProxy is undefined when Model is defined and attached to the Store.

Any help will be appreciated.

Thanks

You defined the User model with a typo:

extends: 'Ext.data.Model',

Should be replaced with

extend: 'Ext.data.Model',

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM