1. #1
    Ext User
    Join Date
    Nov 2010
    Posts
    2
    Vote Rating
    0
    el.nino is on a distinguished road

      0  

    Question 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:
    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"}]}
    (Note: If you want to see a better formatted json string please paste it on http://json.parser.online.fr/)

    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!

  2. #2
    Ext JS Premium Member griffiti93's Avatar
    Join Date
    Mar 2007
    Location
    Owasso, OK
    Posts
    130
    Vote Rating
    0
    griffiti93 is on a distinguished road

      0  

    Default


    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.

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    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);
      }
    });

  4. #4
    Ext User
    Join Date
    Nov 2010
    Posts
    2
    Vote Rating
    0
    el.nino is on a distinguished road

      0  

    Default Yup, perfect solution!

    Yup, perfect solution!


    You guys are the best! Much appreciated

Similar Threads

  1. Reading/Writing multiple stores data alltogether with json
    By hazimdikenli in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 27 Oct 2010, 5:54 AM
  2. reading JSONStore from Text File instead of URL
    By pkellner in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 13 Nov 2008, 6:37 AM
  3. ComboBox Not Reading from JsonStore
    By dancablam in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 24 Sep 2008, 7:24 AM
  4. Example on reading XML With multiple items
    By ppolyzos in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 8 Jan 2008, 3:20 AM

Thread Participants: 2

Tags for this Thread