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; }
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> * @docauthor Evan Trimboli <evan@sencha.com>
21 * Contains a collection of all stores that are created that have an identifier. An identifier can be assigned by
22 * setting the {@link Ext.data.AbstractStore#storeId storeId} property. When a store is in the StoreManager, it can be
23 * referred to via it's identifier:
25 * Ext.create('Ext.data.Store', {
30 * var store = Ext.data.StoreManager.lookup('myStore');
32 * Also note that the {@link #lookup} method is aliased to {@link Ext#getStore} for convenience.
34 * If a store is registered with the StoreManager, you can also refer to the store by it's identifier when registering
35 * it with any Component that consumes data from a store:
37 * Ext.create('Ext.data.Store', {
42 * Ext.create('Ext.view.View', {
44 * // other configuration here
48 Ext.define('Ext.data.StoreManager', {
49 extend: 'Ext.util.MixedCollection',
50 alternateClassName: ['Ext.StoreMgr', 'Ext.data.StoreMgr', 'Ext.StoreManager'],
52 uses: ['Ext.data.ArrayStore'],
54 <span id='Ext-data-StoreManager-cfg-listeners'> /**
55 </span> * @cfg {Object} listeners @hide
58 <span id='Ext-data-StoreManager-method-register'> /**
59 </span> * Registers one or more Stores with the StoreManager. You do not normally need to register stores manually. Any
60 * store initialized with a {@link Ext.data.Store#storeId} will be auto-registered.
61 * @param {Ext.data.Store...} stores Any number of Store instances
63 register : function() {
64 for (var i = 0, s; (s = arguments[i]); i++) {
69 <span id='Ext-data-StoreManager-method-unregister'> /**
70 </span> * Unregisters one or more Stores with the StoreManager
71 * @param {String/Object...} stores Any number of Store instances or ID-s
73 unregister : function() {
74 for (var i = 0, s; (s = arguments[i]); i++) {
75 this.remove(this.lookup(s));
79 <span id='Ext-data-StoreManager-method-lookup'> /**
80 </span> * Gets a registered Store by id
81 * @param {String/Object} store The id of the Store, or a Store instance, or a store configuration
82 * @return {Ext.data.Store}
84 lookup : function(store) {
85 // handle the case when we are given an array or an array of arrays.
86 if (Ext.isArray(store)) {
87 var fields = ['field1'],
88 expand = !Ext.isArray(store[0]),
95 for (i = 0, len = store.length; i < len; ++i) {
96 data.push([store[i]]);
99 for(i = 2, len = store[0].length; i <= len; ++i){
100 fields.push('field' + i);
103 return Ext.create('Ext.data.ArrayStore', {
112 if (Ext.isString(store)) {
114 return this.get(store);
116 // store instance or store config
117 return Ext.data.AbstractStore.create(store);
121 // getKey implementation for MixedCollection
122 getKey : function(o) {
126 <span id='Ext-method-regStore'> /**
127 </span> * Creates a new store for the given id and config, then registers it with the {@link Ext.data.StoreManager Store Mananger}.
130 * Ext.regStore('AllUsers', {
134 * // the store can now easily be used throughout the application
140 * @param {String} id The id to set on the new store
141 * @param {Object} config The store config
145 Ext.regStore = function(name, config) {
148 if (Ext.isObject(name)) {
151 config.storeId = name;
154 if (config instanceof Ext.data.Store) {
157 store = Ext.create('Ext.data.Store', config);
160 return Ext.data.StoreManager.register(store);
163 <span id='Ext-method-getStore'> /**
164 </span> * Shortcut to {@link Ext.data.StoreManager#lookup}.
167 * @alias Ext.data.StoreManager#lookup
169 Ext.getStore = function(name) {
170 return Ext.data.StoreManager.lookup(name);