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
2.8 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.ArrayStore
  17. * @extends Ext.data.Store
  18. * <p>Formerly known as "SimpleStore".</p>
  19. * <p>Small helper class to make creating {@link Ext.data.Store}s from Array data easier.
  20. * An ArrayStore will be automatically configured with a {@link Ext.data.ArrayReader}.</p>
  21. * <p>A store configuration would be something like:<pre><code>
  22. var store = new Ext.data.ArrayStore({
  23. // store configs
  24. autoDestroy: true,
  25. storeId: 'myStore',
  26. // reader configs
  27. idIndex: 0,
  28. fields: [
  29. 'company',
  30. {name: 'price', type: 'float'},
  31. {name: 'change', type: 'float'},
  32. {name: 'pctChange', type: 'float'},
  33. {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
  34. ]
  35. });
  36. * </code></pre></p>
  37. * <p>This store is configured to consume a returned object of the form:<pre><code>
  38. var myData = [
  39. ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
  40. ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
  41. ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
  42. ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
  43. ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
  44. ];
  45. * </code></pre>
  46. * An object literal of this form could also be used as the {@link #data} config option.</p>
  47. * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
  48. * <b>{@link Ext.data.ArrayReader ArrayReader}</b>.</p>
  49. * @constructor
  50. * @param {Object} config
  51. * @xtype arraystore
  52. */
  53. Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
  54. /**
  55. * @cfg {Ext.data.DataReader} reader @hide
  56. */
  57. constructor: function(config){
  58. Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
  59. reader: new Ext.data.ArrayReader(config)
  60. }));
  61. },
  62. loadData : function(data, append){
  63. if(this.expandData === true){
  64. var r = [];
  65. for(var i = 0, len = data.length; i < len; i++){
  66. r[r.length] = [data[i]];
  67. }
  68. data = r;
  69. }
  70. Ext.data.ArrayStore.superclass.loadData.call(this, data, append);
  71. }
  72. });
  73. Ext.reg('arraystore', Ext.data.ArrayStore);
  74. // backwards compat
  75. Ext.data.SimpleStore = Ext.data.ArrayStore;
  76. Ext.reg('simplestore', Ext.data.SimpleStore);