3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.data.ArrayStore"></div>/**
15 * @class Ext.data.ArrayStore
16 * @extends Ext.data.Store
17 * <p>Formerly known as "SimpleStore".</p>
18 * <p>Small helper class to make creating {@link Ext.data.Store}s from Array data easier.
19 * An ArrayStore will be automatically configured with a {@link Ext.data.ArrayReader}.</p>
20 * <p>A store configuration would be something like:<pre><code>
21 var store = new Ext.data.ArrayStore({
29 {name: 'price', type: 'float'},
30 {name: 'change', type: 'float'},
31 {name: 'pctChange', type: 'float'},
32 {name: 'lastChange', type: 'date', dateFormat: 'n/j h:ia'}
36 * <p>This store is configured to consume a returned object of the form:<pre><code>
38 ['3m Co',71.72,0.02,0.03,'9/1 12:00am'],
39 ['Alcoa Inc',29.01,0.42,1.47,'9/1 12:00am'],
40 ['Boeing Co.',75.43,0.53,0.71,'9/1 12:00am'],
41 ['Hewlett-Packard Co.',36.53,-0.03,-0.08,'9/1 12:00am'],
42 ['Wal-Mart Stores, Inc.',45.45,0.73,1.63,'9/1 12:00am']
45 * An object literal of this form could also be used as the {@link #data} config option.</p>
46 * <p><b>*Note:</b> Although not listed here, this class accepts all of the configuration options of
47 * <b>{@link Ext.data.ArrayReader ArrayReader}</b>.</p>
49 * @param {Object} config
52 Ext.data.ArrayStore = Ext.extend(Ext.data.Store, {
53 <div id="cfg-Ext.data.ArrayStore-reader"></div>/**
54 * @cfg {Ext.data.DataReader} reader @hide
56 constructor: function(config){
57 Ext.data.ArrayStore.superclass.constructor.call(this, Ext.apply(config, {
58 reader: new Ext.data.ArrayReader(config)
62 loadData : function(data, append){
63 if(this.expandData === true){
65 for(var i = 0, len = data.length; i < len; i++){
66 r[r.length] = [data[i]];
70 Ext.data.ArrayStore.superclass.loadData.call(this, data, append);
73 Ext.reg('arraystore', Ext.data.ArrayStore);
76 Ext.data.SimpleStore = Ext.data.ArrayStore;
77 Ext.reg('simplestore', Ext.data.SimpleStore);</pre>