Upgrade to ExtJS 3.0.0 - Released 07/06/2009
[extjs.git] / docs / source / StoreMgr.html
1 <html>\r
2 <head>\r
3   <title>The source code</title>\r
4     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
5     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
6 </head>\r
7 <body  onload="prettyPrint();">\r
8     <pre class="prettyprint lang-js"><div id="cls-Ext.StoreMgr"></div>/**
9  * @class Ext.StoreMgr
10  * @extends Ext.util.MixedCollection
11  * The default global group of stores.
12  * @singleton
13  */
14 Ext.StoreMgr = Ext.apply(new Ext.util.MixedCollection(), {
15     <div id="cfg-Ext.StoreMgr-listeners"></div>/**
16      * @cfg {Object} listeners @hide
17      */
18
19     <div id="method-Ext.StoreMgr-register"></div>/**
20      * Registers one or more Stores with the StoreMgr. You do not normally need to register stores
21      * manually.  Any store initialized with a {@link Ext.data.Store#storeId} will be auto-registered. 
22      * @param {Ext.data.Store} store1 A Store instance
23      * @param {Ext.data.Store} store2 (optional)
24      * @param {Ext.data.Store} etc... (optional)
25      */
26     register : function(){
27         for(var i = 0, s; (s = arguments[i]); i++){
28             this.add(s);
29         }
30     },
31
32     <div id="method-Ext.StoreMgr-unregister"></div>/**
33      * Unregisters one or more Stores with the StoreMgr
34      * @param {String/Object} id1 The id of the Store, or a Store instance
35      * @param {String/Object} id2 (optional)
36      * @param {String/Object} etc... (optional)
37      */
38     unregister : function(){
39         for(var i = 0, s; (s = arguments[i]); i++){
40             this.remove(this.lookup(s));
41         }
42     },
43
44     <div id="method-Ext.StoreMgr-lookup"></div>/**
45      * Gets a registered Store by id
46      * @param {String/Object} id The id of the Store, or a Store instance
47      * @return {Ext.data.Store}
48      */
49     lookup : function(id){
50         if(Ext.isArray(id)){
51             var fields = ['field1'], expand = !Ext.isArray(id[0]);
52             if(!expand){
53                 for(var i = 2, len = id[0].length; i <= len; ++i){
54                     fields.push('field' + i);
55                 }
56             }
57             return new Ext.data.ArrayStore({
58                 fields: fields,
59                 data: id,
60                 expandData: expand,
61                 autoDestroy: true,
62                 autoCreated: true
63
64             });
65         }
66         return Ext.isObject(id) ? (id.events ? id : Ext.create(id, 'store')) : this.get(id);
67     },
68
69     // getKey implementation for MixedCollection
70     getKey : function(o){
71          return o.storeId;
72     }
73 });</pre>    \r
74 </body>\r
75 </html>