You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.2 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. This file is part of Ext JS 3.4
  3. Copyright (c) 2011-2013 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as
  7. published by the Free Software Foundation and appearing in the file LICENSE included in the
  8. packaging of this file.
  9. Please review the following information to ensure the GNU General Public License version 3.0
  10. requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  11. If you are unsure which license is appropriate for your use, please contact the sales department
  12. at http://www.sencha.com/contact.
  13. Build date: 2013-04-03 15:07:25
  14. */
  15. /**
  16. * @class Ext.data.XmlStore
  17. * @extends Ext.data.Store
  18. * <p>Small helper class to make creating {@link Ext.data.Store}s from XML data easier.
  19. * A XmlStore will be automatically configured with a {@link Ext.data.XmlReader}.</p>
  20. * <p>A store configuration would be something like:<pre><code>
  21. var store = new Ext.data.XmlStore({
  22. // store configs
  23. autoDestroy: true,
  24. storeId: 'myStore',
  25. url: 'sheldon.xml', // automatically configures a HttpProxy
  26. // reader configs
  27. record: 'Item', // records will have an "Item" tag
  28. idPath: 'ASIN',
  29. totalRecords: '@TotalResults'
  30. fields: [
  31. // set up the fields mapping into the xml doc
  32. // The first needs mapping, the others are very basic
  33. {name: 'Author', mapping: 'ItemAttributes > Author'},
  34. 'Title', 'Manufacturer', 'ProductGroup'
  35. ]
  36. });
  37. * </code></pre></p>
  38. * <p>This store is configured to consume a returned object of the form:<pre><code>
  39. &#60?xml version="1.0" encoding="UTF-8"?>
  40. &#60ItemSearchResponse xmlns="http://webservices.amazon.com/AWSECommerceService/2009-05-15">
  41. &#60Items>
  42. &#60Request>
  43. &#60IsValid>True&#60/IsValid>
  44. &#60ItemSearchRequest>
  45. &#60Author>Sidney Sheldon&#60/Author>
  46. &#60SearchIndex>Books&#60/SearchIndex>
  47. &#60/ItemSearchRequest>
  48. &#60/Request>
  49. &#60TotalResults>203&#60/TotalResults>
  50. &#60TotalPages>21&#60/TotalPages>
  51. &#60Item>
  52. &#60ASIN>0446355453&#60/ASIN>
  53. &#60DetailPageURL>
  54. http://www.amazon.com/
  55. &#60/DetailPageURL>
  56. &#60ItemAttributes>
  57. &#60Author>Sidney Sheldon&#60/Author>
  58. &#60Manufacturer>Warner Books&#60/Manufacturer>
  59. &#60ProductGroup>Book&#60/ProductGroup>
  60. &#60Title>Master of the Game&#60/Title>
  61. &#60/ItemAttributes>
  62. &#60/Item>
  63. &#60/Items>
  64. &#60/ItemSearchResponse>
  65. * </code></pre>
  66. * An object literal of this form could also be used as the {@link #data} config option.</p>
  67. * <p><b>Note:</b> Although not listed here, this class accepts all of the configuration options of
  68. * <b>{@link Ext.data.XmlReader XmlReader}</b>.</p>
  69. * @constructor
  70. * @param {Object} config
  71. * @xtype xmlstore
  72. */
  73. Ext.data.XmlStore = Ext.extend(Ext.data.Store, {
  74. /**
  75. * @cfg {Ext.data.DataReader} reader @hide
  76. */
  77. constructor: function(config){
  78. Ext.data.XmlStore.superclass.constructor.call(this, Ext.apply(config, {
  79. reader: new Ext.data.XmlReader(config)
  80. }));
  81. }
  82. });
  83. Ext.reg('xmlstore', Ext.data.XmlStore);