-
26 Nov 2010 5:16 AM #1
Multiple JsonReaders reading different sections of JsonStore's data
Multiple JsonReaders reading different sections of JsonStore's data
hi guys,
say i have a json string like this:
(Note: If you want to see a better formatted json string please paste it on http://json.parser.online.fr/)Code:{"Staff":[{"id":1,"name":"John"},{"id":2,"name":"Mary"},{"id":3,"name":"Sandra"}],"Students":[{"id":2,"name":"Peter"},{"id":3,"name":"Carl"},{"id":4,"name":"Hodges"}]}
And I have two comboboxes cmbStaff and cmbStudents. is it possible to bind both comoboxes to the same store but having different jsonreaders? i.e. cmbStaff's datareader would read the string with root: 'Staff' and cmbStudent will read the string with root 'Students'?
This is to save the amount of AJAX gets being made by the store and having a different store for every comboBox (imagine if my form had 20 comboboxes!
).
Any ideas? Feel free to inform me if you need any more information
Thanks!
-
26 Nov 2010 6:54 AM #2
The way I've handled this exact scenario before is to make a single AJAX request for all my data. Then setup a store per combobox pointing to the appropriate "root" location for each store. You'll save server requests. It's ok to have a store per combo. The current design of the JsonStore only supports 1 reader.
-
26 Nov 2010 7:33 AM #3Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- The Netherlands
- Posts
- 24,251
- Vote Rating
- 41
Code:store1.load({ callback: function(){ store2.loadData(store1.reader.jsonData); store3.loadData(store1.reader.jsonData); store4.loadData(store1.reader.jsonData); store5.loadData(store1.reader.jsonData); } });
-
26 Nov 2010 9:13 AM #4
Yup, perfect solution!
Yup, perfect solution!
You guys are the best! Much appreciated
Similar Threads
-
Reading/Writing multiple stores data alltogether with json
By hazimdikenli in forum Ext 3.x: Help & DiscussionReplies: 4Last Post: 27 Oct 2010, 5:54 AM -
reading JSONStore from Text File instead of URL
By pkellner in forum Ext 2.x: Help & DiscussionReplies: 3Last Post: 13 Nov 2008, 6:37 AM -
ComboBox Not Reading from JsonStore
By dancablam in forum Ext 2.x: Help & DiscussionReplies: 5Last Post: 24 Sep 2008, 7:24 AM -
Example on reading XML With multiple items
By ppolyzos in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 8 Jan 2008, 3:20 AM


Reply With Quote