-
22 Dec 2011 4:34 AM #1
Answered: List with proxy
Answered: List with proxy
Hi everybody
I am developing a simple Sencha Touch 2 sample with MVC structure.
I want a list view that load a json file and show it. I have listed my code but it doesnt show anything.
Store :
Model :Code:Ext.define('Phonebook.store.Contacts', { extend : 'Ext.data.Store', model : 'Phonebook.model.Contact', sorters : 'lastName', autoLoad : true, proxy: { type: 'ajax', url : 'contacts.json', reader : { type : 'json', root : 'contacts', successProperty : 'success', totalProperty : 'total' } }, });
JSON file :Code:Ext.define('Phonebook.model.Contact', { extend : 'Ext.data.Model', fields : [ { name : 'id', type : 'int' }, { name : 'firstName', type : 'string' }, { name : 'lastName', type : 'string' }, { name : 'email', type : 'string' }, { name : 'tel', type : 'string' } ], });
Code:{ "success" : true, "total" : 2, "contacts" : [ { "id" : 1, "firstName" : "john", "lastName" : "nash", "email" : "j_nash@yahoo.com", "tel" : "09124624557" }, { "id" : 2, "firstName" : "tom", "lastName" : "diaz", "email" : "t_diaz@yahoo.com", "tel" : "09124624667" } ] }
-
Best Answer Posted by mitchellsimoens
-
22 Dec 2011 7:12 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
Using your code, the store is being populated for me.
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.
-
22 Dec 2011 10:22 AM #3
thanks mitchellsimoens,
I am running on local, not on web server, do you think it is the problem cause???
-
22 Dec 2011 11:01 AM #4Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3101
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.
-
22 Dec 2011 11:10 AM #5
mitchellsimoens, it seems that you are a hero in sencha forum.
thanks very much



Reply With Quote