-
20 May 2012 12:36 PM #1
Answered: Stores and Associations
Answered: Stores and Associations
My application has the following structure:
(i) Parent Store (a list of sites and urls)
(ii) Child Store (entries from the URLs defined in the parent store)
In the application I manually define the sites/urls in the parent store, and then kickoff a series of load calls via the proxy to pull the data entries for each site into the child store.
I am trying to manually define a value for a field in the child store for each particular url, so I can identify which site it is from.
E.g.
Parent Store
{name: 'a', site: 'http://....'}
{name: 'b', site: 'http://....'}
Child Store
{someDataFromProxy: '....', siteName:'a'}
{someDataFromProxy: '....', siteName:'a'}
{someDataFromProxy: '....', siteName:'b'}
(i)The site name I want in the child store isn't defined in the feed itself (so that's not an option) and (ii) for the life of me I can't figure out how to pass the siteName from the parent to the child store so that I can set it manually.
Note on (ii) while it is possible for me to pass data from the parent to the child, because I am acting to update the child records manually using the 'load' event, I can only see the last value the was passed from the parent to the child store (i.e. by the time I am acting on the result of the load for site 'a', the data the child store has is site 'b' due to the async nature of the calls/processing).
Someone please help! I can provide the code, but I figured the above explanation would be easier.
-
Best Answer Posted by in4p
Ok,
So I've found a solution to my own problem which works, but is not ideal.
For each record in the parent table, I create a new store instance of the child store and can thus pass values to the store itself (removing the issues of passing variables via the proxy and changing the proxy).
It works, but I would imagine could have memory implications if the number of store instances created grows to large.
Does anyone have a better solution?
-
22 May 2012 5:34 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 34,085
- Vote Rating
- 453
- Answers
- 3153
It should be sending the id of the parent in the load call if I can remember correctly.
If you are doing the load yourself then you could set the parent as an extra param on the proxy
The extra param will be sent on all requests unless overridden from the load method.Code:child.getProxy().setExtraParam('parent', 'parent value')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 May 2012 11:13 AM #3
Thanks Mitchell, unfortunately the problem isn't solved - I guess my initial description wasn't completely clear.
I iterate through the parent records, and for each set the Proxy on the child store (each set of child items comes from a different source) and make the load call.
Since all the child records are using the same store, by the time the load call comes back (async) I no longer have access to the proxy with which it was made - only the most recent proxy persists. Thus I lose the ability to retrieve the extraParam value for anything but the last set of child entries.
Any other suggestions?
-
22 May 2012 12:00 PM #4
Potential Answer
Potential Answer
Ok,
So I've found a solution to my own problem which works, but is not ideal.
For each record in the parent table, I create a new store instance of the child store and can thus pass values to the store itself (removing the issues of passing variables via the proxy and changing the proxy).
It works, but I would imagine could have memory implications if the number of store instances created grows to large.
Does anyone have a better solution?


Reply With Quote