View Full Version : Creating one grid view with multiple stores?

10 Dec 2012, 11:42 AM

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://stackoverflow.com/questions/7775529/extjs4-merge-store-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!

10 Dec 2012, 2:00 PM
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

10 Dec 2012, 2:05 PM
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.


10 Dec 2012, 2:13 PM
Just define your Store and Model like you would normally. After that you could do:

For each source:

url: 'what/ever/seems/best/rest/someObject',
success: function(response, options) {
// ignoring errors and all..
var json = Ext.decode(response.responseText);