4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-data-StoreManager'>/**
19 </span> * @class Ext.data.StoreManager
20 * @extends Ext.util.MixedCollection
21 * <p>Contains a collection of all stores that are created that have an identifier.
22 * An identifier can be assigned by setting the {@link Ext.data.AbstractStore#storeId storeId}
23 * property. When a store is in the StoreManager, it can be referred to via it's identifier:
24 * <pre><code>
25 Ext.create('Ext.data.Store', {
30 var store = Ext.data.StoreManager.lookup('myStore');
31 * </code></pre>
32 * Also note that the {@link #lookup} method is aliased to {@link Ext#getStore} for convenience.</p>
34 * If a store is registered with the StoreManager, you can also refer to the store by it's identifier when
35 * registering it with any Component that consumes data from a store:
36 * <pre><code>
37 Ext.create('Ext.data.Store', {
42 Ext.create('Ext.view.View', {
44 // other configuration here
46 * </code></pre>
49 * @docauthor Evan Trimboli <evan@sencha.com>
50 * TODO: Make this an AbstractMgr
52 Ext.define('Ext.data.StoreManager', {
53 extend: 'Ext.util.MixedCollection',
54 alternateClassName: ['Ext.StoreMgr', 'Ext.data.StoreMgr', 'Ext.StoreManager'],
56 uses: ['Ext.data.ArrayStore'],
58 <span id='Ext-data-StoreManager-cfg-listeners'> /**
59 </span> * @cfg {Object} listeners @hide
62 <span id='Ext-data-StoreManager-method-register'> /**
63 </span> * Registers one or more Stores with the StoreManager. You do not normally need to register stores
64 * manually. Any store initialized with a {@link Ext.data.Store#storeId} will be auto-registered.
65 * @param {Ext.data.Store} store1 A Store instance
66 * @param {Ext.data.Store} store2 (optional)
67 * @param {Ext.data.Store} etc... (optional)
69 register : function() {
70 for (var i = 0, s; (s = arguments[i]); i++) {
75 <span id='Ext-data-StoreManager-method-unregister'> /**
76 </span> * Unregisters one or more Stores with the StoreManager
77 * @param {String/Object} id1 The id of the Store, or a Store instance
78 * @param {String/Object} id2 (optional)
79 * @param {String/Object} etc... (optional)
81 unregister : function() {
82 for (var i = 0, s; (s = arguments[i]); i++) {
83 this.remove(this.lookup(s));
87 <span id='Ext-data-StoreManager-method-lookup'> /**
88 </span> * Gets a registered Store by id
89 * @param {String/Object} id The id of the Store, or a Store instance, or a store configuration
90 * @return {Ext.data.Store}
92 lookup : function(store) {
93 // handle the case when we are given an array or an array of arrays.
94 if (Ext.isArray(store)) {
95 var fields = ['field1'],
96 expand = !Ext.isArray(store[0]),
103 for (i = 0, len = store.length; i < len; ++i) {
104 data.push([store[i]]);
107 for(i = 2, len = store[0].length; i <= len; ++i){
108 fields.push('field' + i);
111 return Ext.create('Ext.data.ArrayStore', {
120 if (Ext.isString(store)) {
122 return this.get(store);
124 // store instance or store config
125 return Ext.data.AbstractStore.create(store);
129 // getKey implementation for MixedCollection
130 getKey : function(o) {
134 <span id='Ext-method-regStore'> /**
135 </span> * <p>Creates a new store for the given id and config, then registers it with the {@link Ext.data.StoreManager Store Mananger}.
136 * Sample usage:</p>
137 <pre><code>
138 Ext.regStore('AllUsers', {
142 //the store can now easily be used throughout the application
147 </code></pre>
148 * @param {String} id The id to set on the new store
149 * @param {Object} config The store config
150 * @param {Constructor} cls The new Component class.
154 Ext.regStore = function(name, config) {
157 if (Ext.isObject(name)) {
160 config.storeId = name;
163 if (config instanceof Ext.data.Store) {
166 store = Ext.create('Ext.data.Store', config);
169 return Ext.data.StoreManager.register(store);
172 <span id='Ext-method-getStore'> /**
173 </span> * Gets a registered Store by id (shortcut to {@link Ext.data.StoreManager#lookup})
174 * @param {String/Object} id The id of the Store, or a Store instance
175 * @return {Ext.data.Store}
179 Ext.getStore = function(name) {
180 return Ext.data.StoreManager.lookup(name);