mhat
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:
<dset>
<foos>
<foo><id>1</id></foo>
...
</foos>
<bars>
<bar><id>1</id></bar>
...
</bars>
</dset>
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]
<dset>
<foos>
<foo><id>1</id></foo>
...
</foos>
<bars>
<bar><id>1</id></bar>
...
</bars>
</dset>
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]