View Full Version : one source xml, more than one store

4 Oct 2007, 8:04 PM
I'm looking for a way to share an single XML response between two Stores. The long and short of it is that I'm trying to reduce the number of distinct HTTP requests. One easy way to do this would be to combine several XML responses into one. The resulting XML is something like this:


It's pretty obvious how to make this work in the 1:1 case, but I'm not having a lot of luck in the 1:N case. Rather than using HttpProxy I figured it would make more sense to use Ajax.request. In the success callback I get a nice XHR object. It seems like the next right step is to use the XmlReader's read method, passing in XHR. This should result in a 'Data Block' suitable for Store.loadData(...) but not so much. I don't get any errors but calling Store.getCount() always indicates zero records.

Ideas? My thinking was that if I could get this to work, I could simply pass the XHR object to two different Stores with Readers that were each configured to look for the right elements [E.g. foo, bar]

4 Oct 2007, 9:11 PM
Looking at how HttpProxy works, I updated the code along the lines of what is below. It still doesn't work but it seems "closer".

var that = this;
'url' : '/xml.html',
'success' : function (xhr) {
var ysto = new Ext.data.Store({
'reader' : that.reader.result,
'proxy' : new Ext.data.MemoryProxy(xhr)

ysto.on('load', function (store, records) {


4 Oct 2007, 9:15 PM
Ahh, I didn't look close enough, MemoryProxy calls reader.readRecord rather than reader.read as HttpProxy does. That seems to resolve the problems. Of course I'm curious if there is a better way (TM).