Properties Methods Events Config Options Direct Link

    Observable
      MixedCollection
        StoreMgr

# Class Ext.StoreMgr

Package: | Ext
Defined In: | StoreMgr.js
Class: | StoreMgr
Extends: | MixedCollection

The default global group of stores.
This class is a singleton and cannot be created directly.

## Config Options

Config Options | Defined By
--- | ---
| listeners : Object A config object containing one or more event handlers to be added to this object during initialization. This should b... A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. | Observable

## Public Properties

This class has no public properties.

## Public Methods

Method | Defined By
--- | ---

add( `String key`, `Object o` ) : Object
Adds an item to the collection. Fires the add event when complete.
Adds an item to the collection. Fires the add event when complete.
Parameters:

- `key` : String
  The key to associate with the item
- `o` : Object
  The item to add.

Returns:

- `Object`
  The item added.

MixedCollection

addAll( `Object/Array objs` ) : void
Adds all elements of an Array or an Object to the collection.
Adds all elements of an Array or an Object to the collection.
Parameters:

- `objs` : Object/Array
  An Object containing properties which will be added to the collection, or an Array of values, each of which are added to the collection.

Returns:

- `void`

MixedCollection

addEvents( `Object object` ) : void
Used to define events on this Observable
Used to define events on this Observable
Parameters:

- `object` : Object
  The object with the events defined

Returns:

- `void`

Observable

addListener( `String eventName`, `Function handler`, [`Object scope`], [`Object options`] ) : void
Appends an event handler to this component
Appends an event handler to this component
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The method the event invokes
- `scope` : Object
  (optional) The scope in which to execute the handler function. The handler function's "this" context.
- `options` : Object
  (optional) An object containing handler configuration properties. This may contain any of the following properties:
  - scope : Object

    The scope in which to execute the handler function. The handler function's "this" context.

  - delay : Number

    The number of milliseconds to delay the invocation of the handler after the event fires.

  - single : Boolean

    True to add a handler to handle just the next firing of the event, and then remove itself.

  - buffer {Number} Causes the handler to be scheduled to run in an Ext.util.DelayedTask delayed by the specified number of milliseconds. If the event fires again within that time, the original handler is not invoked, but the new handler is scheduled in its place.

  Combining Options
  Using the options argument, it is possible to combine different types of listeners:
  A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)

      el.on('click', this.onClick, this, {
          single: true,
          delay: 100,
          forumId: 4
      });

  Attaching multiple handlers in 1 call
  The method also allows for a single argument to be passed which is a config object containing properties which specify multiple handlers.

      foo.on({
          'click' : {
              fn: this.onClick,
              scope: this,
              delay: 100
          },
          'mouseover' : {
              fn: this.onMouseOver,
              scope: this
          },
          'mouseout' : {
              fn: this.onMouseOut,
              scope: this
          }
      });

  Or a shorthand syntax:

      foo.on({
          'click' : this.onClick,
          'mouseover' : this.onMouseOver,
          'mouseout' : this.onMouseOut,
           scope: this
      });

Returns:

- `void`

Observable

clear() : void
Removes all items from the collection. Fires the clear event when complete.
Removes all items from the collection. Fires the clear event when complete.
Parameters:

- None.

Returns:

- `void`

MixedCollection

clone() : MixedCollection
Creates a duplicate of this collection
Creates a duplicate of this collection
Parameters:

- None.

Returns:

- `MixedCollection`

MixedCollection

contains( `Object o` ) : Boolean
Returns true if the collection contains the passed Object as an item.
Returns true if the collection contains the passed Object as an item.
Parameters:

- `o` : Object
  The Object to look for in the collection.

Returns:

- `Boolean`
  True if the collection contains the Object as an item.

MixedCollection

containsKey( `String key` ) : Boolean
Returns true if the collection contains the passed Object as a key.
Returns true if the collection contains the passed Object as a key.
Parameters:

- `key` : String
  The key to look for in the collection.

Returns:

- `Boolean`
  True if the collection contains the Object as a key.

MixedCollection

each( `Function fn`, [`Object scope`] ) : void
Executes the specified function once for every item in the collection, passing the following arguments: item : Mixed...
Executes the specified function once for every item in the collection, passing the following arguments:

- item : Mixed

  The collection item

- index : Number

  The item's index

- length : Number

  The total number of items in the collection

The function should return a boolean value. Returning false from the function will stop the iteration.
Parameters:

- `fn` : Function
  The function to execute for each item.
- `scope` : Object
  (optional) The scope in which to execute the function.

Returns:

- `void`

MixedCollection

eachKey( `Function fn`, [`Object scope`] ) : void
Executes the specified function once for every key in the collection, passing each key, and its associated item as th...
Executes the specified function once for every key in the collection, passing each key, and its associated item as the first two parameters.
Parameters:

- `fn` : Function
  The function to execute for each item.
- `scope` : Object
  (optional) The scope in which to execute the function.

Returns:

- `void`

MixedCollection

filter( `String property`, `String/RegExp value`, [`Boolean anyMatch`], [`Boolean caseSensitive`] ) : MixedCollection
Filter the objects in this collection by a specific property. Returns a new collection that has been filtered.
Filter the objects in this collection by a specific property. Returns a new collection that has been filtered.
Parameters:

- `property` : String
  A property on your objects
- `value` : String/RegExp
  Either string that the property values should start with or a RegExp to test against the property
- `anyMatch` : Boolean
  (optional) True to match any part of the string, not just the beginning
- `caseSensitive` : Boolean
  (optional) True for case sensitive comparison (defaults to False).

Returns:

- `MixedCollection`
  The new filtered collection

MixedCollection

filterBy( `Function fn`, [`Object scope`] ) : MixedCollection
Filter by a function. Returns a new collection that has been filtered. The passed function will be called with each o...
Filter by a function. Returns a new collection that has been filtered. The passed function will be called with each object in the collection. If the function returns true, the value is included otherwise it is filtered.
Parameters:

- `fn` : Function
  The function to be called, it will receive the args o (the object), k (the key)
- `scope` : Object
  (optional) The scope of the function (defaults to this)

Returns:

- `MixedCollection`
  The new filtered collection

MixedCollection

find( `Function fn`, [`Object scope`] ) : Object
Returns the first item in the collection which elicits a true return value from the passed selection function.
Returns the first item in the collection which elicits a true return value from the passed selection function.
Parameters:

- `fn` : Function
  The selection function to execute for each item.
- `scope` : Object
  (optional) The scope in which to execute the function.

Returns:

- `Object`
  The first item in the collection which returned true from the selection function.

MixedCollection

findIndex( `String property`, `String/RegExp value`, [`Number start`], [`Boolean anyMatch`], [`Boolean caseSensitive`] ) : Number
Finds the index of the first matching object in this collection by a specific property/value. Returns a new collectio...
Finds the index of the first matching object in this collection by a specific property/value. Returns a new collection that has been filtered.
Parameters:

- `property` : String
  The name of a property on your objects.
- `value` : String/RegExp
  A string that the property values should start with or a RegExp to test against the property.
- `start` : Number
  (optional) The index to start searching at (defaults to 0).
- `anyMatch` : Boolean
  (optional) True to match any part of the string, not just the beginning.
- `caseSensitive` : Boolean
  (optional) True for case sensitive comparison.

Returns:

- `Number`
  The matched index or -1

MixedCollection

findIndexBy( `Function fn`, [`Object scope`], [`Number start`] ) : Number
Find the index of the first matching object in this collection by a function. If the function returns true it is cons...
Find the index of the first matching object in this collection by a function. If the function returns true it is considered a match.
Parameters:

- `fn` : Function
  The function to be called, it will receive the args o (the object), k (the key).
- `scope` : Object
  (optional) The scope of the function (defaults to this).
- `start` : Number
  (optional) The index to start searching at (defaults to 0).

Returns:

- `Number`
  The matched index or -1

MixedCollection

fireEvent( `String eventName`, `Object... args` ) : Boolean
Fires the specified event with the passed parameters (minus the event name).
Fires the specified event with the passed parameters (minus the event name).
Parameters:

- `eventName` : String
- `args` : Object...
  Variable number of parameters are passed to handlers

Returns:

- `Boolean`
  returns false if any of the handlers return false otherwise it returns true

Observable

first() : Object
Returns the first item in the collection.
Returns the first item in the collection.
Parameters:

- None.

Returns:

- `Object`
  the first item in the collection..

MixedCollection

get( `String/Number key` ) : Object
Returns the item associated with the passed key or index.
Returns the item associated with the passed key or index.
Parameters:

- `key` : String/Number
  The key or index of the item.

Returns:

- `Object`
  The item associated with the passed key.

MixedCollection

getCount() : Number
Returns the number of items in the collection.
Returns the number of items in the collection.
Parameters:

- None.

Returns:

- `Number`
  the number of items in the collection.

MixedCollection

getKey( `Object item` ) : Object
MixedCollection has a generic way to fetch keys if you implement getKey. The default implementation simply returns i...
MixedCollection has a generic way to fetch keys if you implement getKey. The default implementation simply returns `item.id` but you can provide your own implementation to return a different value as in the following examples:

    // normal way
    var mc = new Ext.util.MixedCollection();
    mc.add(someEl.dom.id, someEl);
    mc.add(otherEl.dom.id, otherEl);
    //and so on

    // using getKey
    var mc = new Ext.util.MixedCollection();
    mc.getKey = function(el){
       return el.dom.id;
    };
    mc.add(someEl);
    mc.add(otherEl);

    // or via the constructor
    var mc = new Ext.util.MixedCollection(false, function(el){
       return el.dom.id;
    });
    mc.add(someEl);
    mc.add(otherEl);

Parameters:

- `item` : Object
  The item for which to find the key.

Returns:

- `Object`
  The key for the passed item.

MixedCollection

getRange( [`Number startIndex`], [`Number endIndex`] ) : Array
Returns a range of items in this collection
Returns a range of items in this collection
Parameters:

- `startIndex` : Number
  (optional) defaults to 0
- `endIndex` : Number
  (optional) default to the last item

Returns:

- `Array`
  An array of items

MixedCollection

hasListener( `String eventName` ) : Boolean
Checks to see if this object has any listeners for a specified event
Checks to see if this object has any listeners for a specified event
Parameters:

- `eventName` : String
  The name of the event to check for

Returns:

- `Boolean`
  True if the event is being listened for, else false

Observable

indexOf( `Object o` ) : Number
Returns index within the collection of the passed Object.
Returns index within the collection of the passed Object.
Parameters:

- `o` : Object
  The item to find the index of.

Returns:

- `Number`
  index of the item.

MixedCollection

indexOfKey( `String key` ) : Number
Returns index within the collection of the passed key.
Returns index within the collection of the passed key.
Parameters:

- `key` : String
  The key to find the index of.

Returns:

- `Number`
  index of the key.

MixedCollection

insert( `Number index`, `String key`, [`Object o`] ) : Object
Inserts an item at the specified index in the collection. Fires the add event when complete.
Inserts an item at the specified index in the collection. Fires the add event when complete.
Parameters:

- `index` : Number
  The index to insert the item at.
- `key` : String
  The key to associate with the new item, or the item itself.
- `o` : Object
  (optional) If the second parameter was a key, the new item.

Returns:

- `Object`
  The item inserted.

MixedCollection

item( `String/Number key` ) : Object
Returns the item associated with the passed key OR index. Key has priority over index. This is the equivalent of cal...
Returns the item associated with the passed key OR index. Key has priority over index. This is the equivalent of calling key first, then if nothing matched calling itemAt.
Parameters:

- `key` : String/Number
  The key or index of the item.

Returns:

- `Object`
  The item associated with the passed key.

MixedCollection

itemAt( `Number index` ) : Object
Returns the item at the specified index.
Returns the item at the specified index.
Parameters:

- `index` : Number
  The index of the item.

Returns:

- `Object`
  The item at the specified index.

MixedCollection

key( `String/Number key` ) : Object
Returns the item associated with the passed key.
Returns the item associated with the passed key.
Parameters:

- `key` : String/Number
  The key of the item.

Returns:

- `Object`
  The item associated with the passed key.

MixedCollection

keySort( [`String direction`], [`Function fn`] ) : void
Sorts this collection by keys
Sorts this collection by keys
Parameters:

- `direction` : String
  (optional) "ASC" or "DESC"
- `fn` : Function
  (optional) a comparison function (defaults to case insensitive string)

Returns:

- `void`

MixedCollection

last() : Object
Returns the last item in the collection.
Returns the last item in the collection.
Parameters:

- None.

Returns:

- `Object`
  the last item in the collection..

MixedCollection

lookup( `String/Object id` ) : Ext.data.Store
Gets a registered Store by id
Gets a registered Store by id
Parameters:

- `id` : String/Object
  The id of the Store or a Store

Returns:

- `Ext.data.Store`

StoreMgr

on( `String eventName`, `Function handler`, [`Object scope`], [`Object options`] ) : void
Appends an event handler to this element (shorthand for addListener)
Appends an event handler to this element (shorthand for addListener)
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The method the event invokes
- `scope` : Object
  (optional) The scope in which to execute the handler function. The handler function's "this" context.
- `options` : Object
  (optional)

Returns:

- `void`

Observable

purgeListeners() : void
Removes all listeners for this object
Removes all listeners for this object
Parameters:

- None.

Returns:

- `void`

Observable

remove( `Object o` ) : Object
Removed an item from the collection.
Removed an item from the collection.
Parameters:

- `o` : Object
  The item to remove.

Returns:

- `Object`
  The item removed or false if no item was removed.

MixedCollection

removeAt( `Number index` ) : Object
Remove an item from a specified index in the collection. Fires the remove event when complete.
Remove an item from a specified index in the collection. Fires the remove event when complete.
Parameters:

- `index` : Number
  The index within the collection of the item to remove.

Returns:

- `Object`
  The item removed or false if no item was removed.

MixedCollection

removeKey( `String key` ) : Object
Removed an item associated with the passed key fom the collection.
Removed an item associated with the passed key fom the collection.
Parameters:

- `key` : String
  The key of the item to remove.

Returns:

- `Object`
  The item removed or false if no item was removed.

MixedCollection

removeListener( `String eventName`, `Function handler`, [`Object scope`] ) : void
Removes a listener
Removes a listener
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The handler to remove
- `scope` : Object
  (optional) The scope (this object) for the handler

Returns:

- `void`

Observable

replace( `String key`, [`o {Object}`] ) : Object
Replaces an item in the collection. Fires the replace event when complete.
Replaces an item in the collection. Fires the replace event when complete.
Parameters:

- `key` : String
  The key associated with the item to replace, or the item to replace.
- `{Object}` : o
  o (optional) If the first parameter passed was a key, the item to associate with that key.

Returns:

- `Object`
  The new item.

MixedCollection

resumeEvents() : void
Resume firing events. (see suspendEvents)
Resume firing events. (see suspendEvents)
Parameters:

- None.

Returns:

- `void`

Observable

sort( [`String direction`], [`Function fn`] ) : void
Sorts this collection with the passed comparison function
Sorts this collection with the passed comparison function
Parameters:

- `direction` : String
  (optional) "ASC" or "DESC"
- `fn` : Function
  (optional) comparison function

Returns:

- `void`

MixedCollection

suspendEvents() : void
Suspend the firing of all events. (see resumeEvents)
Suspend the firing of all events. (see resumeEvents)
Parameters:

- None.

Returns:

- `void`

Observable

un( `String eventName`, `Function handler`, [`Object scope`] ) : void
Removes a listener (shorthand for removeListener)
Removes a listener (shorthand for removeListener)
Parameters:

- `eventName` : String
  The type of event to listen for
- `handler` : Function
  The handler to remove
- `scope` : Object
  (optional) The scope (this object) for the handler

Returns:

- `void`

Observable

## Public Events

Event | Defined By
--- | ---

add : ( `Number index`, `Object o`, `String key` )
Fires when an item is added to the collection.
Fires when an item is added to the collection.
Listeners will be called with the following arguments:

- `index` : Number
  The index at which the item was added.
- `o` : Object
  The item added.
- `key` : String
  The key associated with the added item.

MixedCollection

clear : ()
Fires when the collection is cleared.
Fires when the collection is cleared.
Listeners will be called with the following arguments:

- None.

MixedCollection

remove : ( `Object o`, [`String key`] )
Fires when an item is removed from the collection.
Fires when an item is removed from the collection.
Listeners will be called with the following arguments:

- `o` : Object
  The item being removed.
- `key` : String
  (optional) The key associated with the removed item.

MixedCollection

replace : ( `String key`, `Object old`, `Object new` )
Fires when an item is replaced in the collection.
Fires when an item is replaced in the collection.
Listeners will be called with the following arguments:

- `key` : String
  he key associated with the new added.
- `old` : Object
  The item being replaced.
- `new` : Object
  The new item.

MixedCollection