-
15 Oct 2011 5:28 AM #1
Bug with store / ajax proxy ????
Bug with store / ajax proxy ????
Hi,
Maybe found a bug in store.. very annoying...
I made a store with ajax proxy, json format.
When I load the store, the callback has 3 items in records arg, but when I look at the store, he's empty.
Anyone can help ?
-
15 Oct 2011 8:36 AM #2Sencha - Sencha Touch Dev Team
- Join Date
- Mar 2007
- Location
- Redwood City, California
- Posts
- 3,659
- Vote Rating
- 14
Can you post a code sample of your issue please.
-
15 Oct 2011 7:17 PM #3Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
This usually means that your fields don't match what is being returned or your reader isn't setup properly so code for your store and model and the response returned is what is needed to help you
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.
-
16 Oct 2011 3:09 AM #4
The store :
The model:Code:Ext.define('app.store.Seasons', { extend : 'Ext.data.Store', model : 'app.model.Season', requires : [ 'app.model.Season' ], proxy : { type : 'ajax', url : 'data/seasons.json', reader : { type : 'json', root : 'seasons' } }, autoLoad : true });
The response:Code:Ext.define('app.model.Season', { extend : 'Ext.data.Model', fields : [ { name : 'id', type : 'int' }, { name : 'value', type : 'int' }, { name : 'text', type : 'string' } ] });
Code:{ "seasons": [ { "id": 1, "value": 1, "text": "09-10" }, { "id": 2, "value": 2, "text": "10-11" }, { "id": 3, "value": 3, "text": "11-12" } ] }
-
17 Oct 2011 7:47 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
This is exactly what I tried and the store had 3 records in it:
data/seasons.json is exactly this:Code:Ext.define('app.model.Season', { extend : 'Ext.data.Model', fields : [ { name : 'id', type : 'int' }, { name : 'value', type : 'int' }, { name : 'text', type : 'string' } ] }); Ext.define('app.store.Seasons', { extend : 'Ext.data.Store', model : 'app.model.Season', requires : [ 'app.model.Season' ], proxy : { type : 'ajax', url : 'data/seasons.json', reader : { type : 'json', root : 'seasons' } }, autoLoad : true }); Ext.setup({ onReady: function() { var store = Ext.create('app.store.Seasons', { listeners : { load: function(store) { console.log(store); console.log(store.getCount()); //returns 3 console.log(store.data.getCount()); //returns 3 } } }); } });
Code:{ "seasons": [ { "id": 1, "value": 1, "text": "09-10" }, { "id": 2, "value": 2, "text": "10-11" }, { "id": 3, "value": 3, "text": "11-12" } ] }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.
-
17 Oct 2011 7:49 AM #6Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,107
- Vote Rating
- 453
I just had a thought... did you try to get the count of the store after you created the store or in the load event?
Even though it is localstorage and autoLoad is true, there is still time needed for the load to happen so if you did this:
It will return zero. If you look at my post before this one, I do the getCount in the load event listener.Code:var store = Ext.create('app.store.Seasons', {}); console.log(store.getCount());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.
-
17 Oct 2011 9:50 PM #7
Ok, I think I understand my mistake.
I trywithout using the Ext.createCode:this.getSeasonsStore().getCount()
Looks like we can't reproduce the issue or there's a problem in the test case provided.


Reply With Quote