打印版式

Class Ext.util.MixedCollection

Package:Ext.util
Class:MixedCollection
Extends:Observable
Defined In:MixedCollection.js
A Collection class that maintains both numeric indexes and keys and exposes events.

属性   -  方法   -  事件

公共属性

此类没有公共属性。

公共方法

方法 定义对象
  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
将对象中没有的事件从给出的对象中复制过来。
  addListener(String eventName, Function handler, [Object scope], [Object options]) : void Observable
为该组件加入事件处理器函数
  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
触发指定的事件, 并将参数传入(至少要有事件名称)。
  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 E...
  getRange([Number startIndex], [Number endIndex]) : Array MixedCollection
Returns a range of items in this collection
  hasListener(String eventName) : Boolean Observable
检查该对象是否拥有指定事件的侦听器
  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 options]) : void Observable
为该组件加入事件处理器函数, addListener 的简写方式
  purgeListeners() : void Observable
从对象身上移除所有的侦听器
  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
移除侦听器
  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
移除侦听器, removeListener 的简写方式

公共事件

事件 定义对象
  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.

构造函数

MixedCollection

public function MixedCollection(Boolean allowFunctions, Function keyFn)
参数:
  • allowFunctions : Boolean
    True if the addAll function should add function references to the collection (defaults to false)
  • keyFn : Function
    A function that can accept an item of the type(s) stored in this MixedCollection and return the key value for that item. This is used when available to look up the key on items that were passed without an explicit key parameter to a MixedCollection method. Passing this parameter is equivalent to providing an implementation for the getKey method.

方法详情

add

public function add(String key, Object o)
Adds an item to the collection.
参数:
  • key : String
    The key to associate with the item
  • o : Object
    The item to add.
返回:
  • Object
    The item added.
This method is defined by MixedCollection.

addAll

public function addAll(Object/Array objs)
Adds all elements of an Array or an Object to the collection.
参数:
  • 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.
返回:
  • void
This method is defined by MixedCollection.

addEvents

public function addEvents(Object object)
将对象中没有的事件从给出的对象中复制过来。给出的对象必须也继承于 Observable 对象此方法才会有效果。
参数:
  • object : Object
    要复制事件的源对象
返回:
  • void
This method is defined by Observable.

addListener

public function addListener(String eventName, Function handler, [Object scope], [Object options])
为组件添加一个事件监听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • scope : Object
    (可选)处理函数执行的作用域。处理函数 "this" 的内容。
  • options : Object
    (可选)一个包含处理设置属性的对象。可以包含下列的属性:
    • scope {Object} 处理函数执行的作用域。处理函数 "this" 的内容。
    • delegate {String} 一个简单的选择器用来过滤目标或查找目标的子节点。
    • stopEvent {Boolean} 值为 True 时用来中止事件。那样将中止传播,并防止缺省动作。
    • preventDefault {Boolean} 值为 True 时用来防止缺省动作。
    • stopPropagation {Boolean} 值为 True 时用来中止事件传播。
    • normalized {Boolean} 值为 False 时向处理函数传递浏览器事件用以代替 Ext.EventObject 对象。
    • delay {Number} 当事件触发后启用处理函数的延迟微秒数。
    • single {Boolean} 值为 True 时将添加一个处理函数用来处理下个触发的事件,并在处理完后移除。
    • buffer {Number} 使处理函数计划在由 Ext.util.DelayedTask 指定的微秒数后执行。如果事件在延迟期间再次触发,原来的处理函数将不再启动,而是由新的计划代替。

    组合选项
    使用选项参数可以组合不同类型的监听器:

    下面是一个标准的、延迟执行的、一次性的监听器,将会自动停止事件并传递一个自定义的参数(forumId)

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

    这个方法也允许传递的单个参数是一个包含多个指定处理函数的设置对象。

    一次调用多个处理函数
    代码:

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

    或者简写为:
    代码:

    el.on({ 'click' : this.onClick, 'mouseover' : this.onMouseOver, 'mouseout' : this.onMouseOut scope: this });
返回:
  • void
This method is defined by Observable.

clear

public function clear()
Removes all items from the collection.
参数:
  • 无。
返回:
  • void
This method is defined by MixedCollection.

clone

public function clone()
Creates a duplicate of this collection
参数:
  • 无。
返回:
  • MixedCollection
This method is defined by MixedCollection.

contains

public function contains(Object o)
Returns true if the collection contains the passed Object as an item.
参数:
  • o : Object
    The Object to look for in the collection.
返回:
  • Boolean
    True if the collection contains the Object as an item.
This method is defined by MixedCollection.

containsKey

public function containsKey(String key)
Returns true if the collection contains the passed Object as a key.
参数:
  • key : String
    The key to look for in the collection.
返回:
  • Boolean
    True if the collection contains the Object as a key.
This method is defined by MixedCollection.

each

public function each(Function fn, [Object scope])
Executes the specified function once for every item in the collection, passing each item as the first and only parameter. returning false from the function will stop the iteration.
参数:
  • fn : Function
    The function to execute for each item.
  • scope : Object
    (可选) The scope in which to execute the function.
返回:
  • void
This method is defined by MixedCollection.

eachKey

public function eachKey(Function fn, [Object scope])
Executes the specified function once for every key in the collection, passing each key, and its associated item as the first two parameters.
参数:
  • fn : Function
    The function to execute for each item.
  • scope : Object
    (可选) The scope in which to execute the function.
返回:
  • void
This method is defined by MixedCollection.

filter

public function filter(String property, String/RegExp value)
Filter the objects in this collection by a specific property. Returns a new collection that has been filtered.
参数:
  • 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
返回:
  • MixedCollection
    The new filtered collection
This method is defined by MixedCollection.

filterBy

public function filterBy(Function fn, [Object scope])
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.
参数:
  • fn : Function
    The function to be called, it will receive the args o (the object), k (the key)
  • scope : Object
    (可选) The scope of the function (defaults to this)
返回:
  • MixedCollection
    The new filtered collection
This method is defined by MixedCollection.

find

public function find(Function fn, [Object scope])
Returns the first item in the collection which elicits a true return value from the passed selection function.
参数:
  • fn : Function
    The selection function to execute for each item.
  • scope : Object
    (可选) The scope in which to execute the function.
返回:
  • Object
    The first item in the collection which returned true from the selection function.
This method is defined by MixedCollection.

fireEvent

public function fireEvent(String eventName, Object... args)
触发指定的事件并给出参数(至少要有事件名称)。
参数:
  • eventName : String
  • args : Object...
    传入处理函数的参数
返回:
  • Boolean
    如果任何处理函数返回 false 则返回值为 false, 否则返回 true。
This method is defined by Observable.

first

public function first()
Returns the first item in the collection.
参数:
  • 无。
返回:
  • Object
    the first item in the collection..
This method is defined by MixedCollection.

get

public function get(String/Number key)
Returns the item associated with the passed key or index.
参数:
  • key : String/Number
    The key or index of the item.
返回:
  • Object
    The item associated with the passed key.
This method is defined by MixedCollection.

getCount

public function getCount()
Returns the number of items in the collection.
参数:
  • 无。
返回:
  • Number
    the number of items in the collection.
This method is defined by MixedCollection.

getKey

public function getKey(o {Object})
MixedCollection has a generic way to fetch keys if you implement getKey.

    // 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);
    // etc
    
                
参数:
  • {Object} : o
    The item for which to find the key.
返回:
  • Object
    The key for the passed item.
This method is defined by MixedCollection.

getRange

public function getRange([Number startIndex], [Number endIndex])
Returns a range of items in this collection
参数:
  • startIndex : Number
    (可选) defaults to 0
  • endIndex : Number
    (可选) default to the last item
返回:
  • Array
    An array of items
This method is defined by MixedCollection.

hasListener

public function hasListener(String eventName)
检查该对象是否拥有指定事件的侦听器
参数:
  • eventName : String
    查询事件之名称
返回:
  • Boolean
    值为 True 值表示事件监听器存在, 否则值为 false。
This method is defined by Observable.

indexOf

public function indexOf(Object o)
Returns index within the collection of the passed Object.
参数:
  • o : Object
    The item to find the index of.
返回:
  • Number
    index of the item.
This method is defined by MixedCollection.

indexOfKey

public function indexOfKey(String key)
Returns index within the collection of the passed key.
参数:
  • key : String
    The key to find the index of.
返回:
  • Number
    index of the key.
This method is defined by MixedCollection.

insert

public function insert(Number index, String key, [Object o])
Inserts an item at the specified index in the collection.
参数:
  • 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
    (可选) If the second parameter was a key, the new item.
返回:
  • Object
    The item inserted.
This method is defined by MixedCollection.

item

public function item(String/Number key)
Returns the item associated with the passed key OR index. Key has priority over index.
参数:
  • key : String/Number
    The key or index of the item.
返回:
  • Object
    The item associated with the passed key.
This method is defined by MixedCollection.

itemAt

public function itemAt(Number index)
Returns the item at the specified index.
参数:
  • index : Number
    The index of the item.
返回:
  • Object
This method is defined by MixedCollection.

key

public function key(String/Number key)
Returns the item associated with the passed key.
参数:
  • key : String/Number
    The key of the item.
返回:
  • Object
    The item associated with the passed key.
This method is defined by MixedCollection.

keySort

public function keySort([String direction], [Function fn])
Sorts this collection by keys
参数:
  • direction : String
    (可选) "ASC" or "DESC"
  • fn : Function
    (可选) a comparison function (defaults to case insensitive string)
返回:
  • void
This method is defined by MixedCollection.

last

public function last()
Returns the last item in the collection.
参数:
  • 无。
返回:
  • Object
    the last item in the collection..
This method is defined by MixedCollection.

on

public function on(String eventName, Function handler, [Object options])
为该组件加入事件处理器函数, addListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    事件调用的方法
  • options : Object
    (可选)
返回:
  • void
This method is defined by Observable.

purgeListeners

public function purgeListeners()
从对象身上移除所有的侦听器
参数:
  • 无。
返回:
  • void
This method is defined by Observable.

remove

public function remove(Object o)
Removed an item from the collection.
参数:
  • o : Object
    The item to remove.
返回:
  • Object
    The item removed.
This method is defined by MixedCollection.

removeAt

public function removeAt(Number index)
Remove an item from a specified index in the collection.
参数:
  • index : Number
    The index within the collection of the item to remove.
返回:
  • void
This method is defined by MixedCollection.

removeKey

public function removeKey(String key)
Removed an item associated with the passed key fom the collection.
参数:
  • key : String
    The key of the item to remove.
返回:
  • void
This method is defined by MixedCollection.

removeListener

public function removeListener(String eventName, Function handler, [Object scope])
移除侦听器
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

replace

public function replace(String key, [o {Object}])
Replaces an item in the collection.
参数:
  • key : String
    The key associated with the item to replace, or the item to replace.
  • {Object} : o
    o (可选) If the first parameter passed was a key, the item to associate with that key.
返回:
  • Object
    The new item.
This method is defined by MixedCollection.

sort

public function sort([String direction], [Function fn])
Sorts this collection with the passed comparison function
参数:
  • direction : String
    (可选) "ASC" or "DESC"
  • fn : Function
    (可选) comparison function
返回:
  • void
This method is defined by MixedCollection.

un

public function un(String eventName, Function handler, [Object scope])
移除侦听器, removeListener 的简写方式
参数:
  • eventName : String
    侦听事件的类型
  • handler : Function
    删除的处理函数
  • scope : Object
    (可选) The scope (this object) for the handler
返回:
  • void
This method is defined by Observable.

事件详情

add

public event add
Fires when an item is added to the collection.
Subscribers will be called with the following parameters:
  • index : Number
    The index at which the item was added.
  • o : Object
    The item added.
  • key : String
    The key associated with the added item.
This event is defined by MixedCollection.

clear

public event clear
Fires when the collection is cleared.
Subscribers will be called with the following parameters:
  • 无。
This event is defined by MixedCollection.

remove

public event remove
Fires when an item is removed from the collection.
Subscribers will be called with the following parameters:
  • o : Object
    The item being removed.
  • key : String
    (可选) The key associated with the removed item.
This event is defined by MixedCollection.

replace

public event replace
Fires when an item is replaced in the collection.
Subscribers will be called with the following parameters:
  • key : String
    he key associated with the new added.
  • old : Object
    The item being replaced.
  • new : Object
    The new item.
This event is defined by MixedCollection.

Ext - Copyright © 2006-2007 Ext JS, LLC
All rights reserved.