Hybrid View

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    2
    Vote Rating
    0
    jsa7690 is on a distinguished road

      0  

    Default Unanswered: Creating one grid view with multiple stores?

    Unanswered: Creating one grid view with multiple stores?


    Hi-

    I'm new to ExtJS and am creating my first application. The goal of my application is to display JSON data that is being passed to me (10 different calls to be exact) in a single grid view. All of the JSON data has the exact same fields.

    However, as far as I can tell, I can only connect my single view to a single store. In the case of my app though, I have 10 different stores.

    What should be the solution? I have looked at all of the following with no avail:
    http://serversideguy.com/2012/01/31/...ng-store-data/
    http://stackoverflow.com/questions/7...e-into-another http://www.hightechinthehub.com/2012/06/extjs-multiple-stores-for-single-request/

    Is there are way to connect the view to multiple stores or is there a proper way to merge all the stores into one? I have read that this really should be done on the service side but I'm trying to do it through ExtJS.

    Let me know if you have an answer, much appreciated!

  2. #2
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    If you are just reading the data, I would not create different stores for all the different sources but just get the data into one Store with Ajax requests.

    If you need to write to the sources, you could try to create a new store for each store and copy records on load like in your serversideguy link. Then you can also use the original sources for writes since the records themselves would hold changes and you can still sync the substores.

    But its all a bit hacky, I would still recommend doing it server side

    EDIT: Ding 300 posts

  3. #3
    Sencha User
    Join Date
    Dec 2012
    Posts
    2
    Vote Rating
    0
    jsa7690 is on a distinguished road

      0  

    Default


    Flanders- thanks for your response.

    I think that would be the best approach- one store with multiple ajax requests. Do you know of any examples or anything in the docs that shows one store getting data from multiple ajax reuqests? This would be exactly what I am looking for.

    Thanks!

  4. #4
    Sencha User
    Join Date
    Dec 2009
    Location
    Enschede, The Netherlands
    Posts
    327
    Answers
    16
    Vote Rating
    13
    flanders will become famous soon enough

      0  

    Default


    Just define your Store and Model like you would normally. After that you could do:

    For each source:
    Code:
    Ext.Ajax.request({
      url: 'what/ever/seems/best/rest/someObject',
      success: function(response, options) {
        // ignoring errors and all..
        var json = Ext.decode(response.responseText);
        getYourStoreSomehow.loadData(json.data);
      }
    });

Thread Participants: 1

Tags for this Thread