简体   繁体   中英

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.

 <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. The information in tag2 will be using for display in a panel.

I know that it is possible to make 2 ajax call query to 2 different store for 2 different purpose.

But to minimize the ajax call, which mean I only need to do 1 ajax call. Is that possible to define an extjs model that store such this xml format?

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. You are missing an id for your items though, so either add one inside the xml or use the model id generator.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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