X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/6a7e4474cba9d8be4b2ec445e10f1691f7277c50..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/src/data/ArrayStore.js?ds=sidebyside diff --git a/src/data/ArrayStore.js b/src/data/ArrayStore.js index 3e061bc2..718dbce9 100644 --- a/src/data/ArrayStore.js +++ b/src/data/ArrayStore.js @@ -1,22 +1,20 @@ -/*! - * Ext JS Library 3.2.0 - * Copyright(c) 2006-2010 Ext JS, Inc. - * licensing@extjs.com - * http://www.extjs.com/license - */ /** + * @author Ed Spencer * @class Ext.data.ArrayStore * @extends Ext.data.Store - *
Formerly known as "SimpleStore".
+ * @ignore + * *Small helper class to make creating {@link Ext.data.Store}s from Array data easier. - * An ArrayStore will be automatically configured with a {@link Ext.data.ArrayReader}.
- *A store configuration would be something like:
+ * An ArrayStore will be automatically configured with a {@link Ext.data.reader.Array}.
+ *
+ * A store configuration would be something like:
+
var store = new Ext.data.ArrayStore({
// store configs
autoDestroy: true,
storeId: 'myStore',
// reader configs
- idIndex: 0,
+ idIndex: 0,
fields: [
'company',
{name: 'price', type: 'float'},
@@ -25,8 +23,9 @@ var store = new Ext.data.ArrayStore({
{name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
]
});
- *
- * This store is configured to consume a returned object of the form:
+
+ * This store is configured to consume a returned object of the form:
+
var myData = [
['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
@@ -34,37 +33,55 @@ var myData = [
['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
];
- *
- * An object literal of this form could also be used as the {@link #data} config option.
- * *Note: Although not listed here, this class accepts all of the configuration options of
- * {@link Ext.data.ArrayReader ArrayReader}.
+
+*
+ * An object literal of this form could also be used as the {@link #data} config option.
+ * + **Note: Although not listed here, this class accepts all of the configuration options of + * {@link Ext.data.reader.Array ArrayReader}.
+ * * @constructor * @param {Object} config * @xtype arraystore */ -Ext.data.ArrayStore = Ext.extend(Ext.data.Store, { +Ext.define('Ext.data.ArrayStore', { + extend: 'Ext.data.Store', + alias: 'store.array', + uses: ['Ext.data.reader.Array'], + /** * @cfg {Ext.data.DataReader} reader @hide */ - constructor: function(config){ - Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, { - reader: new Ext.data.ArrayReader(config) - })); + constructor: function(config) { + config = config || {}; + + Ext.applyIf(config, { + proxy: { + type: 'memory', + reader: 'array' + } + }); + + this.callParent([config]); }, - loadData : function(data, append){ - if(this.expandData === true){ - var r = []; - for(var i = 0, len = data.length; i < len; i++){ + loadData: function(data, append) { + if (this.expandData === true) { + var r = [], + i = 0, + ln = data.length; + + for (; i < ln; i++) { r[r.length] = [data[i]]; } + data = r; } - Ext.data.ArrayStore.superclass.loadData.call(this, data, append); + + this.callParent([data, append]); } +}, function() { + // backwards compat + Ext.data.SimpleStore = Ext.data.ArrayStore; + // Ext.reg('simplestore', Ext.data.SimpleStore); }); -Ext.reg('arraystore', Ext.data.ArrayStore); - -// backwards compat -Ext.data.SimpleStore = Ext.data.ArrayStore; -Ext.reg('simplestore', Ext.data.SimpleStore); \ No newline at end of file