ArrayStore.html 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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'>/**
  19. </span> * @author Ed Spencer
  20. *
  21. * Small helper class to make creating {@link Ext.data.Store}s from Array data easier. An ArrayStore will be
  22. * automatically configured with a {@link Ext.data.reader.Array}.
  23. *
  24. * A store configuration would be something like:
  25. *
  26. * var store = Ext.create('Ext.data.ArrayStore', {
  27. * // store configs
  28. * storeId: 'myStore',
  29. * // reader configs
  30. * fields: [
  31. * 'company',
  32. * {name: 'price', type: 'float'},
  33. * {name: 'change', type: 'float'},
  34. * {name: 'pctChange', type: 'float'},
  35. * {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  36. * ]
  37. * });
  38. *
  39. * This store is configured to consume a returned object of the form:
  40. *
  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. *
  49. * An object literal of this form could also be used as the {@link #cfg-data} config option.
  50. *
  51. */
  52. Ext.define('Ext.data.ArrayStore', {
  53. extend: 'Ext.data.Store',
  54. alias: 'store.array',
  55. requires: [
  56. 'Ext.data.proxy.Memory',
  57. 'Ext.data.reader.Array'
  58. ],
  59. constructor: function(config) {
  60. config = Ext.apply({
  61. proxy: {
  62. type: 'memory',
  63. reader: 'array'
  64. }
  65. }, config);
  66. this.callParent([config]);
  67. },
  68. loadData: function(data, append) {
  69. if (this.expandData === true) {
  70. var r = [],
  71. i = 0,
  72. ln = data.length;
  73. for (; i &lt; ln; i++) {
  74. r[r.length] = [data[i]];
  75. }
  76. data = r;
  77. }
  78. this.callParent([data, append]);
  79. }
  80. }, function() {
  81. // backwards compat
  82. Ext.data.SimpleStore = Ext.data.ArrayStore;
  83. // Ext.reg('simplestore', Ext.data.SimpleStore);
  84. });</pre>
  85. </body>
  86. </html>