-
1 Feb 2012 8:33 PM #1
Answered: Ext.data is undefined
Answered: Ext.data is undefined
I'm trying to get my code to work with the b1 release and I am getting the message of
Ext.data is undefined for the following code:
I see that Ext.data.TreeStore is in the api so why am I getting this error?Code:var store = new Ext.data.TreeStore({ model: 'ListItem', defaultRootProperty: 'items', root: data // the list of dogs });
I use to include sencha-touch-all.js and I do not see this file so I am now using sencha-touch.js
Thanks in advance for your assistance.
-
Best Answer Posted by edspencer
You just forgot to extend Ext.data.Model in your ListItem class - should look like this:
Note also that I moved the fields config into the config object, otherwise you'll get a console warningCode:Ext.define('ListItem', { extend: 'Ext.data.Model', config: { fields: [ {name: 'name', type: 'string'}, {name: 'avatar', type: 'string'}, {name: 'sex', type: 'string'}, {name: 'age', type: 'string'}, {name: 'goodkids', type: 'string'}, {name: 'gooddogs', type: 'string'}, {name: 'goodcats', type: 'string'}, {name: 'house', type: 'string'}, {name: 'crate', type: 'string'}, {name: 'weight', type: 'string'}, {name: 'ns', type: 'string'}, {name: 'desc', type: 'string'}, {name: 'leaf', type: 'type'} ] } });
-
2 Feb 2012 12:30 PM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,623
- Vote Rating
- 434
- Answers
- 3103
You need to require that file in order to use it if you are going to use Ext.Loader
Or you can use a wildcard:Code:Ext.require([ 'Ext.data.TreeStore' ]);
And that will load all the files in the Ext.data namespaceCode:Ext.require([ 'Ext.data.*' ]);Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Feb 2012 1:18 PM #3
Still having issues.
I now have:
And now I have get this error:Code:Ext.require(['Ext.MessageBox', 'Ext.data.*', 'Ext.event.*', ]);
Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. Missing required class: Ext.MessageBox.
-
2 Feb 2012 1:26 PM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,623
- Vote Rating
- 434
- Answers
- 3103
You should be using sencha-touch-debug.js
Ext.Loader should be enabled by default in that file, if not then you can do this:
Code:Ext.Loader.setConfig({ enabled : true });Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
2 Feb 2012 2:11 PM #5
Getting closer, I hope.
I now have:
[ERROR][Ext.data.Store#setModel] Model with name undefined doesnt exist.
and it is referring to the following:
Code:var data = { text: 'Dogs', items: [ {name: 'Berlin', avatar: 'vgsr_images/Berlin.jpg', sex: 'Male', age:'8 Years Old', weight: '71.5 lbs.', goodkids: 'Yes', gooddogs: 'Yes', goodcats: 'Yes', house: 'Yes', crate: 'No', ns: 'Yes', desc: '<p style="width:90%">Berlin is an 8yo neutered male German Shepherd with a gorgeous white coat dropped off at a shelter by his family that had to move. </p>', leaf: true} ] }; Ext.define('ListItem', { fields: [ {name: 'name', type: 'string'}, {name: 'avatar', type: 'string'}, {name: 'sex', type: 'string'}, {name: 'age', type: 'string'}, {name: 'goodkids', type: 'string'}, {name: 'gooddogs', type: 'string'}, {name: 'goodcats', type: 'string'}, {name: 'house', type: 'string'}, {name: 'crate', type: 'string'}, {name: 'weight', type: 'string'}, {name: 'ns', type: 'string'}, {name: 'desc', type: 'string'}, {name: 'leaf', type: 'type'} ] }); var store = new Ext.data.TreeStore({ model: 'ListItem', defaultRootProperty: 'items', root: data // the list });
-
2 Feb 2012 3:43 PM #6Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
- Answers
- 29
You just forgot to extend Ext.data.Model in your ListItem class - should look like this:
Note also that I moved the fields config into the config object, otherwise you'll get a console warningCode:Ext.define('ListItem', { extend: 'Ext.data.Model', config: { fields: [ {name: 'name', type: 'string'}, {name: 'avatar', type: 'string'}, {name: 'sex', type: 'string'}, {name: 'age', type: 'string'}, {name: 'goodkids', type: 'string'}, {name: 'gooddogs', type: 'string'}, {name: 'goodcats', type: 'string'}, {name: 'house', type: 'string'}, {name: 'crate', type: 'string'}, {name: 'weight', type: 'string'}, {name: 'ns', type: 'string'}, {name: 'desc', type: 'string'}, {name: 'leaf', type: 'type'} ] } });Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
2 Feb 2012 7:51 PM #7
Solved
Solved
Ed, thanks it now works.
Sencha Touch is awesome, I volunteer for animal rescue groups and I used it to produce this website that everyone loves: http://www.vgsr.org and helps us in our mission. I greatly appreciate all the hard work
and dedication that the team puts into it.
-
2 Feb 2012 10:31 PM #8Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
- Answers
- 29
I checked out the app, looking good! I have a few suggestions on how you can make your app code easier to maintain, would you mind if I use your app as an example in a blog post? In return I'll give you the full app adhering to best practices, and the community will have a nice example app to learn from.
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
3 Feb 2012 7:02 AM #9
Ed,
That would be fantastic, I would not mind at all. I know it needs to change to MVC format, I've just been nervous about attempting it. Myself, our group, and the dogs, thank you for any assistance you can provide us with. I will be placing this code at GitHub with an open source license and I hope it will benefit other rescue groups. Let me know if you need anything from me to develop the example.
Bruce


Reply With Quote