PDA

View Full Version : me.model is undefined



lz3404
11 Jun 2012, 1:41 AM
I got an error width: me.model is undefined when i change a MVC app to normal app into desktop project.
I want to change the MVC's view(a grid panel) to desktop's module. so i did this:


Ext.define('CSMS.view.PresentView', {
extend : 'Ext.grid.Panel',
alias : 'widget.present',

//store : 'PresentStore', //Comment out store config
requires : ['CSMS.store.PresentStore'], //then add the store requires class

title : 'Present Info',
layout : 'fit',

autoShow : true,

......
initComponent : function(){

this.store = CSMS.store.PresentStore;
//and then Assignment the store in the initComponet function.

this.columns = [ ];

this.callParent(arguments);

}

my PresentStore.js is


Ext.define('CSMS.store.PresentStore', {
extend : 'Ext.data.Store',
requires: ['CSMS.model.PresentModel'], //add model class
model : 'CSMS.model.PresentModel', //config model

autoSync : true,

pageSize : 25,
autoLoad : {
start: 0,
limit : 24
},


proxy : {

type : 'ajax',
api : {
read : 'present',
update : 'preupdate',
create : 'data/update.jsp'
},

reader : {

type : 'json',
root : 'present',
successProperty : false,
totalProperty : 'totalCount'
},

writer : {

type : 'json',
writeAllFields : false

}
}
});
when run this project, the error occurs.
I'm puzzled about this, i referenced the article:
http://www.sencha.com/blog/using-ext-loader-for-your-application/

lz3404
11 Jun 2012, 1:53 AM
I also want to find some solutions from the other guy's thread,
http://www.sencha.com/forum/showthread.php?131895-me.model-is-undefined
and
http://www.sencha.com/forum/showthread.php?209901




Timing matters. The model must be loaded before the store is created. Take a look at the network tab, do you see the model file being loaded?

Try adding a requires block to the store to include the model.
Then i look at the network tab,
36114

scottmartin
11 Jun 2012, 7:27 AM
If you use ext-all-dev.js, it should display the dependency errors that exists based on your loader config. This is detailed in the article that you referenced in your first post.

Regards,
Scott.

lz3404
11 Jun 2012, 7:42 AM
If you use ext-all-dev.js, it should display the dependency errors that exists based on your loader config. This is detailed in the article that you referenced in your first post.

Regards,
Scott.
yes, i use bootstrap.js ,it use ext-all-dev.js. but there are no dependency errors occured.
i'm sure i had required CSMS.store.PresentStore in the PresentView.js and required CSMS.model.PresentModel in the PresentStore.js. you an look at the code in my first post.

if it was dependency error, i would never puzzled.
additional,even i used fields:[] in the PresentStore, the "me.model is undefined" error is still...

lz3404
11 Jun 2012, 10:27 PM
i solved it by my-self, thank you for all.

scottmartin
12 Jun 2012, 7:34 AM
Can you please provide the solution so others can benefit?

Regards,
Scott.