PageRenderTime 201ms CodeModel.GetById 35ms RepoModel.GetById 1ms app.codeStats 0ms

/ext-4.0.7/src/data/XmlStore.js

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