Package: | Ext.util |
Class: | MixedCollection |
Extends: | Observable |
Defined In: | MixedCollection.js |
Method | Defined By | |
---|---|---|
MixedCollection( Boolean allowFunctions , Function keyFn ) |
MixedCollection | |
add( String key , Object o ) : Object |
MixedCollection | |
Adds an item to the collection. | ||
addAll( Object/Array objs ) : void |
MixedCollection | |
Adds all elements of an Array or an Object to the collection. | ||
addEvents( Object object ) : void |
Observable | |
Used to define events on this Observable | ||
addListener( String eventName , Function handler , [Object scope ], [Object options ] ) : void |
Observable | |
Appends an event handler to this component | ||
clear() : void | MixedCollection | |
Removes all items from the collection. | ||
clone() : MixedCollection | MixedCollection | |
Creates a duplicate of this collection | ||
contains( Object o ) : Boolean |
MixedCollection | |
Returns true if the collection contains the passed Object as an item. | ||
containsKey( String key ) : Boolean |
MixedCollection | |
Returns true if the collection contains the passed Object as a key. | ||
each( Function fn , [Object scope ] ) : void |
MixedCollection | |
Executes the specified function once for every item in the collection, passing each item as the first and only parame... | ||
eachKey( Function fn , [Object scope ] ) : void |
MixedCollection | |
Executes the specified function once for every key in the collection, passing each key, and its associated item as th... | ||
filter( String property , String/RegExp value ) : MixedCollection |
MixedCollection | |
Filter the objects in this collection by a specific property. Returns a new collection that has been filtered. | ||
filterBy( Function fn , [Object scope ] ) : MixedCollection |
MixedCollection | |
Filter by a function. * Returns a new collection that has been filtered. The passed function will be called with each... | ||
find( Function fn , [Object scope ] ) : Object |
MixedCollection | |
Returns the first item in the collection which elicits a true return value from the passed selection function. | ||
fireEvent( String eventName , Object... args ) : Boolean |
Observable | |
Fires the specified event with the passed parameters (minus the event name). | ||
first() : Object | MixedCollection | |
Returns the first item in the collection. | ||
get( String/Number key ) : Object |
MixedCollection | |
Returns the item associated with the passed key or index. | ||
getCount() : Number | MixedCollection | |
Returns the number of items in the collection. | ||
getKey( o {Object} ) : Object |
MixedCollection | |
MixedCollection has a generic way to fetch keys if you implement getKey. // normal way var mc = new Ext.util.MixedCo... | ||
getRange( [Number startIndex ], [Number endIndex ] ) : Array |
MixedCollection | |
Returns a range of items in this collection | ||
hasListener( String eventName ) : Boolean |
Observable | |
Checks to see if this object has any listeners for a specified event | ||
indexOf( Object o ) : Number |
MixedCollection | |
Returns index within the collection of the passed Object. | ||
indexOfKey( String key ) : Number |
MixedCollection | |
Returns index within the collection of the passed key. | ||
insert( Number index , String key , [Object o ] ) : Object |
MixedCollection | |
Inserts an item at the specified index in the collection. | ||
item( String/Number key ) : Object |
MixedCollection | |
Returns the item associated with the passed key OR index. Key has priority over index. | ||
itemAt( Number index ) : Object |
MixedCollection | |
Returns the item at the specified index. | ||
key( String/Number key ) : Object |
MixedCollection | |
Returns the item associated with the passed key. | ||
keySort( [String direction ], [Function fn ] ) : void |
MixedCollection | |
Sorts this collection by keys | ||
last() : Object | MixedCollection | |
Returns the last item in the collection. | ||
on( String eventName , Function handler , [Object scope ], [Object options ] ) : void |
Observable | |
Appends an event handler to this element (shorthand for addListener) | ||
purgeListeners() : void | Observable | |
Removes all listeners for this object | ||
remove( Object o ) : Object |
MixedCollection | |
Removed an item from the collection. | ||
removeAt( Number index ) : void |
MixedCollection | |
Remove an item from a specified index in the collection. | ||
removeKey( String key ) : void |
MixedCollection | |
Removed an item associated with the passed key fom the collection. | ||
removeListener( String eventName , Function handler , [Object scope ] ) : void |
Observable | |
Removes a listener | ||
replace( String key , [o {Object} ] ) : Object |
MixedCollection | |
Replaces an item in the collection. | ||
sort( [String direction ], [Function fn ] ) : void |
MixedCollection | |
Sorts this collection with the passed comparison function | ||
un( String eventName , Function handler , [Object scope ] ) : void |
Observable | |
Removes a listener (shorthand for removeListener) |
Event | Defined By | |
---|---|---|
add : ( Number index , Object o , String key ) |
MixedCollection | |
Fires when an item is added to the collection. | ||
clear : () | MixedCollection | |
Fires when the collection is cleared. | ||
remove : ( Object o , [String key ] ) |
MixedCollection | |
Fires when an item is removed from the collection. | ||
replace : ( String key , Object old , Object new ) |
MixedCollection | |
Fires when an item is replaced in the collection. |
public function MixedCollection( Boolean allowFunctions
, Function keyFn
)
allowFunctions
: BooleankeyFn
: Functionpublic function add( String key
, Object o
)
key
: Stringo
: ObjectObject
public function addAll( Object/Array objs
)
objs
: Object/Arrayvoid
public function addEvents( Object object
)
object
: Objectvoid
public function addListener( String eventName
, Function handler
, [Object scope
], [Object options
] )
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Object
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.
el.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 which passes the same scope object to all handlers:
el.on({
'click': this.onClick,
'mouseover': this.onMouseOver,
'mouseout': this.onMouseOut,
scope: this
});
void
public function clear()
void
public function clone()
MixedCollection
public function contains( Object o
)
o
: ObjectBoolean
public function containsKey( String key
)
key
: StringBoolean
public function each( Function fn
, [Object scope
] )
fn
: Functionscope
: Objectvoid
public function eachKey( Function fn
, [Object scope
] )
fn
: Functionscope
: Objectvoid
public function filter( String property
, String/RegExp value
)
property
: Stringvalue
: String/RegExpMixedCollection
public function filterBy( Function fn
, [Object scope
] )
fn
: Functionscope
: ObjectMixedCollection
public function find( Function fn
, [Object scope
] )
fn
: Functionscope
: ObjectObject
public function fireEvent( String eventName
, Object... args
)
eventName
: Stringargs
: Object...Boolean
public function first()
Object
public function get( String/Number key
)
key
: String/NumberObject
public function getCount()
Number
public function getKey( o {Object}
)
// 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);
{Object}
: oObject
public function getRange( [Number startIndex
], [Number endIndex
] )
startIndex
: NumberendIndex
: NumberArray
public function hasListener( String eventName
)
eventName
: StringBoolean
public function indexOf( Object o
)
o
: ObjectNumber
public function indexOfKey( String key
)
key
: StringNumber
public function insert( Number index
, String key
, [Object o
] )
index
: Numberkey
: Stringo
: ObjectObject
public function item( String/Number key
)
key
: String/NumberObject
public function itemAt( Number index
)
index
: NumberObject
public function key( String/Number key
)
key
: String/NumberObject
public function keySort( [String direction
], [Function fn
] )
direction
: Stringfn
: Functionvoid
public function last()
Object
public function on( String eventName
, Function handler
, [Object scope
], [Object options
] )
eventName
: Stringhandler
: Functionscope
: Objectoptions
: Objectvoid
public function purgeListeners()
void
public function remove( Object o
)
o
: ObjectObject
public function removeAt( Number index
)
index
: Numbervoid
public function removeKey( String key
)
key
: Stringvoid
public function removeListener( String eventName
, Function handler
, [Object scope
] )
eventName
: Stringhandler
: Functionscope
: Objectvoid
public function replace( String key
, [o {Object}
] )
key
: String{Object}
: oObject
public function sort( [String direction
], [Function fn
] )
direction
: Stringfn
: Functionvoid
public function un( String eventName
, Function handler
, [Object scope
] )
eventName
: Stringhandler
: Functionscope
: Objectvoid
public event add
index
: Numbero
: Objectkey
: Stringpublic event clear
public event remove
o
: Objectkey
: Stringpublic event replace
key
: Stringold
: Objectnew
: Object