PDA

View Full Version : Cannot call method 'getProxy' of undefined



no0b
3 Dec 2011, 4:10 AM
I started with this example: http://www.sencha.com/blog/using-ext-loader-for-your-application
What I want is to change the "on-script" data from grid with another data from my database. For this, I did the following changes:


Ext.define('Elearning.stores.UserStore', {
extend : 'Ext.data.Store',
requires : ['Elearning.models.UserModel'],
storeId : 'usersStore',


model : 'Elearning.models.UserModel',
proxy: {
type: 'ajax',
url : '/data/getUsers.php',
reader: {
type: 'json',
root: 'users'
}
},
autoLoad: true,

constructor : function() {
this.callParent(arguments);
}
});


I also edited the file UsersGridPanel.js

Ext.define('Elearning.views.UsersGridPanel', {
extend : 'Ext.grid.Panel',
alias : 'widget.UsersGridPanel',
requires : ['Elearning.stores.UserStore'],


initComponent : function() {
this.store = Elearning.stores.UserStore;
this.columns = this.buildColumns();
this.callParent();
},
buildColumns : function() {
return [
{
header : 'First Name',
dataIndex : 'nume',
width : 70
},
{
header : 'Last Name',
dataIndex : 'prenume',
width : 70
},
{
header : 'Email',
dataIndex : 'email',
width : 70
},
{
header : 'Username',
dataIndex : 'username',
width : 70
}
];
}
});

Unfortunately, I got an error (on Chrome console) at the red line described below with the error message Cannot call method 'getProxy' of undefined

initComponent : function() {
this.store = Elearning.stores.UserStore;
this.columns = this.buildColumns();
this.callParent();
},


Thanks in advance.

redraid
3 Dec 2011, 5:57 AM
initComponent : function() {
this.store = Ext.create('Elearning.stores.UserStore');
// or:
// this.store = 'Elearning.stores.UserStore';
this.columns = this.buildColumns();
this.callParent(arguments);
},

no0b
3 Dec 2011, 6:18 AM
It works and..hard to be a ...noob!

Thanks!




initComponent : function() {
this.store = Ext.create('Elearning.stores.UserStore');
// or:
// this.store = 'Elearning.stores.UserStore';
this.columns = this.buildColumns();
this.callParent(arguments);
},

alukic
18 Jun 2013, 2:22 PM
I had the same problem, and this resolved it. Thank you! If anyone can explain why this works:

this.store = Ext.create('Elearning.stores.UserStore');

and this does not:

this.store = 'Elearning.stores.UserStore';

Tim Toady
18 Jun 2013, 7:38 PM
Because the store config property must be in an instance of the store or the storeId of a store registered with StoreManager. The code specified in the first post has the storeId 'usersStore'. Personally, I would just let the controller create the store for me, not specify a storeId, and use 'UserStore' .

alukic
20 Jun 2013, 7:29 AM
Thanks Tim.