PDA

View Full Version : Split JSON into 2 JsonStores



guys2008
19 Nov 2010, 10:28 AM
Hey,

I'm trying to create a data binding screen, that its west side displays names and its east side displays pictures.
I'm getting the following JSON from the server :

{"friends":
[{"uid":"874420436","name":"George Avisar","photos":[]},
{"uid":"671342850","name":"Tom Factor","photos":[]},
{"uid":"767058141","name":"Benjamin Dweck","photos":[]},
{"uid":"691081778","name":"Tal Washington","photos":[{"url":"thumbs\/691081778_0.jpg","yaw":85.52},{"url":"thumbs\/691081778_1.jpg","yaw":48.08}]}
]}

How can I create two JsonStores - one that holds only uid and name and the second holds the photos - without calling the .php two times ??:-/

Thanks,

fay
19 Nov 2010, 10:52 AM
See http://www.sencha.com/forum/showthread.php?50430-Reusing-one-call-for-several-JsonStores

wongpat
19 Nov 2010, 6:21 PM
Hey,

I'm trying to create a data binding screen, that its west side displays names and its east side displays pictures.
I'm getting the following JSON from the server :

{"friends":
[{"uid":"874420436","name":"George Avisar","photos":[]},
{"uid":"671342850","name":"Tom Factor","photos":[]},
{"uid":"767058141","name":"Benjamin Dweck","photos":[]},
{"uid":"691081778","name":"Tal Washington","photos":[{"url":"thumbs\/691081778_0.jpg","yaw":85.52},{"url":"thumbs\/691081778_1.jpg","yaw":48.08}]}
]}

How can I create two JsonStores - one that holds only uid and name and the second holds the photos - without calling the .php two times ??:-/

Thanks,

You don't need to call the server twice and separate out the data. Just use the same information and define your list and your right view to use exactly the data you need. Reference the same JSONStore so you don't have duplicate data.

guys2008
20 Nov 2010, 8:01 AM
Thanks wongpat. In the end I split the big array into two small arrays and created arrayStore for each one of them...