-
27 Dec 2011 4:39 PM #1
Unanswered: JSon Data not loaded into store data
Unanswered: JSon Data not loaded into store data
I have a form I want to load data into from a JSon store. Currently my application has a list that the user can click the disclose button on. This in turn calls a function with the internalId and creates a store and loads the data from the server into a json table with one row. When inspecting the store it appears to have no data but if you check the network you can see the call to the server and the json data returned.
Thanks for your help.Code:ShowEditForm: function(recordID) { var viewport = this.getViewport(), topToolbar = viewport.down('titlebar[docked=top]'), newCard = viewport.add({xtype: 'rdpmobile-woaddchange'}); var store = Ext.create('RDPMobile.store.WorkOrders.WorkOrder'); store.load({ params: {WorkOrderID: recordID}}); newCard.setRecord(store.getAt(0)); viewport.setActiveItem(newCard); topToolbar.setTitle('Change Work Order'); }
Ron
-
28 Dec 2011 6:06 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
This is usually due to the reader not setup correctly. Like is there a root... are the fields setup correctly
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.
-
28 Dec 2011 6:25 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
- Answers
- 83
Ron, store.load is going to fire off an ajax request, which is asynchronous.
this is why newCard.setRecord(store.getAt(0)) fails. Because the store has no data at that point in time.
What you need to do is setup the following logic in a "load" handler for the data store.
Code:newCard.setRecord(store.getAt(0)); viewport.setActiveItem(newCard); topToolbar.setTitle('Change Work Order');
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
28 Dec 2011 8:04 AM #4
Jay,
Would you have an example of this using MVC. I am not sure how to setup this up in the controller.
Thanks
Ron
-
28 Dec 2011 8:08 AM #5Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
You should either set a listener for the load event or use the callback method in the load method:
orCode:store.on('load', someFn, store); store.load();
My preference is the first.Code:store.load({ callback : someFn });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.
-
28 Dec 2011 8:12 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
- Answers
- 83
should be:
Code:ShowEditForm: function(recordID) { // this == instance of controller //only register the load listener once! store.on('load', this.onStoreLoad, this); store.load({ params: {WorkOrderID: recordID}}); }
in your onStoreLoad:
Code:onStoreLoad : function(store) { var viewport = this.getViewport(), topToolbar = viewport.down('titlebar[docked=top]'), newCard = viewport.add({xtype: 'rdpmobile-woaddchange'}); newCard.setRecord(store.getAt(0)); viewport.setActiveItem(newCard); topToolbar.setTitle('Change Work Order'); }
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
28 Dec 2011 8:16 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
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.
-
28 Dec 2011 8:41 AM #8Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,169
- Vote Rating
- 28
- Answers
- 83
calm down dude
.
he asked for an example in the context of a controller.


Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
28 Dec 2011 8:45 AM #9Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,656
- Vote Rating
- 436
- Answers
- 3108
I am calm... everyone asks for example code but that doesn't seem to really teach people. Getting them to do some research seems to be giving a better impact.
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.
-
28 Dec 2011 9:18 AM #10
Mitchell,
I understand your point I deal with people all the time looking for the problem to be solved for them without having to do some leg work or learning from an example given. If I am posting something I have usually spent several hours looking for an answer and though guidance is good sometimes a good working example can go a long way. A good example of this is the MVC example you posted. Before this I was still struggling with the setup and the connection of the files. Now, it is totally clear.
Anyhow, I have tried the examples but when I set the store up with:
I get the following error: Uncaught Error: [ERROR][RDPMobile.controller.WorkOrders.Monitor#getObservableId] Invalid unique id of 'WorkOrders.Monitor' for this objectCode:store.on('load',this.DataLoaded, this);
If i remove 'this' from the code then the 'this' context of the DataLoaded function is the store and not the controller.
Thanks again for your help.
Ron


Reply With Quote