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.

83 lines
3.2 KiB

2 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-data-ArrayStore-method-constructor'><span id='Ext-data-ArrayStore'>/**
  19. </span></span> * @class Ext.data.ArrayStore
  20. * @extends Ext.data.Store
  21. * &lt;p&gt;Formerly known as &quot;SimpleStore&quot;.&lt;/p&gt;
  22. * &lt;p&gt;Small helper class to make creating {@link Ext.data.Store}s from Array data easier.
  23. * An ArrayStore will be automatically configured with a {@link Ext.data.ArrayReader}.&lt;/p&gt;
  24. * &lt;p&gt;A store configuration would be something like:&lt;pre&gt;&lt;code&gt;
  25. var store = new Ext.data.ArrayStore({
  26. // store configs
  27. autoDestroy: true,
  28. storeId: 'myStore',
  29. // reader configs
  30. idIndex: 0,
  31. fields: [
  32. 'company',
  33. {name: 'price', type: 'float'},
  34. {name: 'change', type: 'float'},
  35. {name: 'pctChange', type: 'float'},
  36. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  37. ]
  38. });
  39. * &lt;/code&gt;&lt;/pre&gt;&lt;/p&gt;
  40. * &lt;p&gt;This store is configured to consume a returned object of the form:&lt;pre&gt;&lt;code&gt;
  41. var myData = [
  42. ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  43. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  44. ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
  45. ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  46. ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
  47. ];
  48. * &lt;/code&gt;&lt;/pre&gt;
  49. * An object literal of this form could also be used as the {@link #data} config option.&lt;/p&gt;
  50. * &lt;p&gt;&lt;b&gt;*Note:&lt;/b&gt; Although not listed here, this class accepts all of the configuration options of
  51. * &lt;b&gt;{@link Ext.data.ArrayReader ArrayReader}&lt;/b&gt;.&lt;/p&gt;
  52. * @constructor
  53. * @param {Object} config
  54. * @xtype arraystore
  55. */
  56. Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
  57. <span id='Ext-data-ArrayStore-cfg-reader'> /**
  58. </span> * @cfg {Ext.data.DataReader} reader @hide
  59. */
  60. constructor: function(config){
  61. Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
  62. reader: new Ext.data.ArrayReader(config)
  63. }));
  64. },
  65. <span id='Ext-data-ArrayStore-method-loadData'> loadData : function(data, append){
  66. </span> if(this.expandData === true){
  67. var r = [];
  68. for(var i = 0, len = data.length; i &lt; len; i++){
  69. r[r.length] = [data[i]];
  70. }
  71. data = r;
  72. }
  73. Ext.data.ArrayStore.superclass.loadData.call(this, data, append);
  74. }
  75. });
  76. Ext.reg('arraystore', Ext.data.ArrayStore);
  77. // backwards compat
  78. Ext.data.SimpleStore = Ext.data.ArrayStore;
  79. Ext.reg('simplestore', Ext.data.SimpleStore);</pre>
  80. </body>
  81. </html>