-
8 Jun 2012 7:26 AM #1
Unanswered: Loading nested data into two different stores
Unanswered: Loading nested data into two different stores
I have two models that are related. One is called 'Changes' and belongsTo a 'Configuration'. This is how I've defined the association on a 'Change':
On the changes store I have a proxy defined like this:Code:associations: [{ type:'belongsTo', model:'Changes.model.Configuration', primaryKey: 'id', foreignKey: 'configuration_id', associationKey: 'configurations' }],
When the store is loaded it is passed a JSON object that looks like this:Code:proxy: { type: 'ajax', url: 'services/changes.php', reader: { type: 'json', rootProperty: 'changes' } },
When the record gets loaded I can call 'record.getConfiguration()' but all of the fields in 'data' show null (except id shows: ext-record-9). Inside the raw array there is one object that shows all of the fields with the data loaded from the JSON. Can anyone see why the data isn't being read into a new Configuration object and saved to the Configuration store?Code:{ "success": true, "changes": [ { "id": 1, "changeId": "CMS19178263", "briefDescription": "Loaded from Proxy!!!", "configuration_id": 3, "configurations": [ { "id": "3", "longName": "002669-2669-abc_-_windows_7_desktop.Computer.Windows", "ciName": "002669-2669-abc_-_windows_7_desktop" } ] } ] }
Let me know if I need to post anymore information...
-
10 Jun 2012 9:55 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,624
- Vote Rating
- 434
- Answers
- 3105
Try making the configurations property value an object instead of an array in your JSON.
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.
-
18 Jun 2012 7:27 AM #3
Doing that made it so the configuration showed up as an associated object of the change. But it doesn't load it into the configuration store. Now I'm thinking it's going to be better to load the two stores separately (with flat instead of nested JSON). But will the change objects get automatically associated with their respective configuration objects if the associations definitions are setup correctly on each model? Or is that not a feature built into the framework?


Reply With Quote