开发者

reuse proxy call data for extjs store

开发者 https://www.devze.com 2022-12-31 16:56 出处:网络
I have a xml tha开发者_开发技巧t i need to bind to XTemplate. The XML structure is as follows <Name>

I have a xml tha开发者_开发技巧t i need to bind to XTemplate. The XML structure is as follows

<Name>
 <Student_Name>
     <First>John</First>
     <Last>Smith</Last>
 </Student_Name>
 <Student_Name>
     <First>John</First>
     <Last>Doe</Last>
 </Student_Name>
 <Faculty_Name>
     <First>Johny</First>
     <Last>Byrd</Last>
 </Student_Name>
</Name>

I am using Ext.data.Store with proxyurl tot he xml, Ext.data.XML reader to rad the xml and a listener that bind the data to the Xtemplate. The xmlreader needs a root node to be specified and i have to give root name as "Student_Name" It need to bind it to one more store for "Faculty_Name" as the root node. SO i end up calling my service to get xml twice. Is there a way to call service once to get the xml and bind it to two stores with different root nodes.


At the risk of sounding like Captain Obvious, you actually need 2 root nodes in your data. I would also suggest renaming your nodes (if possible) to eliminate redundancy and make your XML more semantically logical, e.g.,

<People>
 <Students>
  <Name>
     <First>John</First>
     <Last>Smith</Last>
  </Name>
  <Name>
     <First>John</First>
     <Last>Doe</Last>
  </Name>
 </Students>
 <Faculty>
  <Name>
     <First>Johny</First>
     <Last>Byrd</Last>
  </Name>
 </Faculty>
</People>

That way Students and Faculty can be your 2 separate root nodes and you'll only need a single server call.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号