简体   繁体   English

如何为此xml格式创建EXTJS模型

[英]How to create EXTJS model for this xml format

This is the xml format that I will get when I got the return from ajax call. 这是从ajax调用返回时将得到的xml格式。

 <root>
   <tag1>
         <item>
              <name>....</name>
              <des>......</des>
         </item>
         <item>
              <name>....</name>
              <des>......</des>
         </item>
         <item>
              <name>....</name>
              <des>......</des>
         </item>
         ......<more item here >...............
   </tag1>
   <tag2>
       <key>.....</key>
       <spec>....</spec>
   </tag2>
</root>

I will use the item inside tag 1 for a grid table. 我将标签1内的项目用于表格。 The information in tag2 will be using for display in a panel. tag2中的信息将用于在面板中显示。

I know that it is possible to make 2 ajax call query to 2 different store for 2 different purpose. 我知道可以为2个不同的目的向2个不同的存储区进行2个ajax调用查询。

But to minimize the ajax call, which mean I only need to do 1 ajax call. 但是要最小化ajax调用,这意味着我只需要执行1个ajax调用。 Is that possible to define an extjs model that store such this xml format? 可以定义一个extjs模型来存储这种xml格式吗?

If yes, can you make an example of it? 如果是,您可以举一个例子吗?

Thank you. 谢谢。

You can make a store that loads the first part of the xml and use the same rawdata and the load event of the store to load the second store. 您可以创建一个存储来加载xml的第一部分,并使用相同的原始数据和存储的load事件来加载第二个存储。 You are missing an id for your items though, so either add one inside the xml or use the model id generator. 不过,您缺少商品的ID,因此请在xml中添加一个ID或使用模型ID生成器。

    mainStore.mon(mainStore, 'load',
        function(store, records, successful) {
            var rawData = store.getProxy().getReader().rawData;
            secondaryStore.loadRawData(rawData);
        });
    mainStore.load();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM