ext MixedCollection 类

MixedCollection 类所在包: util 
所在文件: MixedCollection.js
全称: Ext.util.MixedCollection
父类: Observable

一个Collection类持有数字索引,键和暴露了事件。

A Collection class that maintains both numeric indexes and keys and exposes events.

配置选项配置选项 继承自
  listeners : Object
在初始期间,一个配置对象包含的一个或更多的事件句柄会添加到对象.这...
在初始期间,一个配置对象包含的一个或更多的事件句柄会添加到对象.这应该是有效的监听者配置对象,就像在addListener 例子里有指定附属的多个句柄.

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
已公开的方法方法 继承自
  MixedCollection (  Boolean allowFunctions, Function keyFn )
...
参数:
 
allowFunctions : Boolean
True如果addAll函数应该添加函数跟collection有关(默认falase)

True if the addAll function should add function references to the collection (defaults to false)

keyFn : Function
函数能接受一个存储在MixedCollection里的类型的一项和返回那一项的键值.这很有用,当能够查看能通过不需要一个准确的键入参数到MixedCollection 方法.目前这个参数等同于提供了getKey 方法的实现.

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.

返回值:
  MixedCollection
  add (  String key, Object o ) : Object
添加一项进集合,引发add 时间,当结束的时候 Adds an item to the collection. Fire...
添加一项进集合,引发add 时间,当结束的时候

Adds an item to the collection. Fires the add event when complete.

参数:
 
key : String
键值关联的项或是新项.

如果你提供了一个MixedCollection的getKey 实现,或如果你存储项的键值是一个叫id,那么MixedCollection 将会能得到新项的键值.这种情况能转递新项进那个参数.

The key to associate with the item, or the new item.

If you supplied a getKey implementation for this MixedCollection, or if the key of your stored items is in a property called id, then the MixedCollection will be able to derive the key for the new item. In this case just pass the new item in this parameter.

o : Object
The item to add.
返回值:
 
Object
添加的项

The item added.
 MixedCollection
  addAll (  Object/Array objs ) : void
添加数组的所有元素或是集合中的一个对象. Adds all elements of an Array or an O...
添加数组的所有元素或是集合中的一个对象.

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  MixedCollection
  addEvents (  Object object ) : void
通常用来定义Observable 上的事件. Used to define events on this Observable ...
通常用来定义Observable 上的事件.

Used to define events on this Observable

参数:
 
object : Object
时间定义的对象

The object with the events defined

返回值:
 
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

参数:
 
eventName : String
监听的时间类型

The type of event to listen for

handler : Function
时间调用的方法

The method the event invokes

scope : Object
执行句柄的范围.句柄函数用"this"上下文.

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

options : Object
一个对象包含了处理配置的选项。它可以包括以下的选项:

scope(范围):object

        执行函数的范围。处理程序的"this"上下文.

delay(延时):Number

        事件触发后延迟数毫秒后条用处理函数.

single:boolean

        真--添加一个句柄处理当下个事件触发时并删除自己.

 buffer:Number

        延迟指定的毫秒后,引发预定的处理函数运行在一个Ext.util.DelayedTask  .如果事件在那段时间里再触发,原先的处理程序不会被调用,但是新的处理程序的地址没变.

结合参数

用参数,它能够结合不同类型的监听器.

一个平常,延迟,一次性的监听器会自动停止事件并通过一个习惯的观点.

el.on('click', this.onClick, this, {    single: true,    delay: 100,    forumId: 4});
在一个调用中包含多个处理程序

这个方法也允许一个单一参数通过一个配置对象包含指定的多个处理程序.

foo.on({    'click' : {        fn: this.onClick,        scope: this,        delay: 100    },    'mouseover' : {        fn: this.onMouseOver,        scope: this    },    'mouseout' : {        fn: this.onMouseOut,        scope: this    }});
或是一个速记的标记:

foo.on({    'click' : this.onClick,    'mouseover' : this.onMouseOver,    'mouseout' : this.onMouseOut,     scope: this});
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});
返回值:
 
void  Observable
  clear (   ) : void
从集合中删除所有项.触发clear事件,当完成的时候. Removes all items from the c...
从集合中删除所有项.触发clear事件,当完成的时候.

Removes all items from the collection. Fires the clear event when complete.

返回值:
 
void  MixedCollection
  clone (   ) : MixedCollection
创建集合的一个副本. Creates a duplicate of this collection
创建集合的一个副本.

Creates a duplicate of this collection

返回值:
 
MixedCollection  MixedCollection
  contains (  Object o ) : Boolean
如果集合包含已有的项,返回true. Returns true if the collection contains the passed ...
如果集合包含已有的项,返回true.

Returns true if the collection contains the passed Object as an item.

参数:
 
o : Object
要在集合里查找的对象.

The Object to look for in the collection.

返回值:
 
Boolean
True如果集合包含那一项.

True if the collection contains the Object as an item.
 MixedCollection
  containsKey (  String key ) : Boolean
如果集合包含键,返回true. Returns true if the collection contains the passed Object as...
如果集合包含键,返回true.

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. MixedCollection
  each (   ) : void
为集合中的每一项执行指定的函数,传递以下的参数: item : Mixed   ...
为集合中的每一项执行指定的函数,传递以下的参数:

item : Mixed

      集合中的项

index : Number

      项的索引

length : Number

      集合中项的总数

函数会返回一个boolean 值.函数返回false将会停止迭代.

参数:

fn:每项将要执行的函数.

scope:函数执行的范围.

返回:

 void

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. : Function
The function to execute for each item.
scope : Object (optional) The scope in which to execute the function. : Object
(optional) The scope in which to execute the function.
Returns:
 
void
返回值:
 
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 the first two parameters.

参数:
 
fn : Function
每一项执行的函数.

The function to execute for each item.

scope : Object
执行函数的范围.

The scope in which to execute the function.

返回值:
 
void  MixedCollection
  filter (  String property, String/RegExp value, Boolean anyMatch, Boolean caseSensitive ) : MixedCollection
通过一个指定的属性筛选集合中的对象.返回一个被筛选过的集合. Filter th...
通过一个指定的属性筛选集合中的对象.返回一个被筛选过的集合.

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

anyMatch : Boolean
True,匹配字符的任何一部分,而不只是开始.

True to match any part of the string, not just the beginning

caseSensitive : Boolean
True时,大小写比较敏感.(默认是false)

True for case sensitive comparison (defaults to False).

返回值:
 
MixedCollection
新的被筛选过的集合

The new filtered collection
 MixedCollection
  filterBy (  Function fn, Object scope ) : MixedCollection
通过一个函数筛选。返回一个被筛选过的新的集合.被传递的函数将会被集...
通过一个函数筛选。返回一个被筛选过的新的集合.被传递的函数将会被集合中的每一项调用.如果函数返回true,值被包含否侧它被过滤.

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
被调用的函数,它将收到参数o (the object), k (the key)

The function to be called, it will receive the args o (the object), k (the key)

scope : Object
函数执行的范围(默认是this)

The scope of the function (defaults to this)

返回值:
 
MixedCollection
新的被筛选过的集合

The new filtered collection
 MixedCollection
  find (  Function fn, Object scope ) : Object
集合中返回能通过选择函数筛选并返回true值的第一项. Returns the first item i...
集合中返回能通过选择函数筛选并返回true值的第一项.

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
集合中能通过选择函数并返回true值的第一项.

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 fir...
通过一个指定的属性/值,找到第一个匹配对象的索引.

Finds the index of the first matching object in this collection by a specific property/value.

参数:
 
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
开始查询的索引(默认是0)

The index to start searching at (defaults to 0).

anyMatch : Boolean
True匹配字符串的任一部分,而不是开始.

True to match any part of the string, not just the beginning.

caseSensitive : Boolean
True时大小写比较敏感.

True for case sensitive comparison.

返回值:
 
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 ret...
Find the index of the first matching object in this collection by a function. If the function returns true it is considered a match.
参数:
 
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).
start : Number
The index to start searching at (defaults to 0).
返回值:
 
Number
The matched index or -1 MixedCollection
  fireEvent (  String eventName, Object... args ) : Boolean
引发指定的事件带着要传递的参数(最少事件的名字) Fires the specified eve...
引发指定的事件带着要传递的参数(最少事件的名字)

Fires the specified event with the passed parameters (minus the event name).

参数:
 
eventName : String
args : Object...
可变数目的参数被传递到处理函数.

Variable number of parameters are passed to handlers

返回值:
 
Boolean
处理函数中的任意一个返回false,就返回false,否则返回真.

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.

返回值:
 
Object
集合中的第一项.

the first item in the collection..
 MixedCollection
  get (  String/Number key ) : Object
返回跟传递过来的键值或索引值相关的项. Returns the item associated with the pas...
返回跟传递过来的键值或索引值相关的项.

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. MixedCollection
  getCount (   ) : Number
返回集合中项的数目. Returns the number of items in the collection.
返回集合中项的数目.

Returns the number of items in the collection.

返回值:
 
Number
集合中项的数目.

the number of items in the collection.
 MixedCollection
  getKey (  Object item ) : Object
MixedCollection 有一种普通的方式去取键值如果你实现了getKey.默认的实现简卮..
MixedCollection 有一种普通的方式去取键值如果你实现了getKey.默认的实现简单地返回item.id但是你能提供你自己的实现去返回一个不同的值就像下面的例子.

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 wayvar mc = new Ext.util.MixedCollection();mc.add(someEl.dom.id, someEl);mc.add(otherEl.dom.id, otherEl);//and so on// using getKeyvar mc = new Ext.util.MixedCollection();mc.getKey = function(el){   return el.dom.id;};mc.add(someEl);mc.add(otherEl);// or via the constructorvar mc = new Ext.util.MixedCollection(false, function(el){   return el.dom.id;});mc.add(someEl);mc.add(otherEl);
参数:
 
item : Object
The item for which to find the key.
返回值:
 
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

参数:
 
startIndex : Number
默认是0

defaults to 0

endIndex : Number
默认是最后的一项

default to the last item

返回值:
 
Array
项的数组.

An array of items
 MixedCollection
  hasListener (  String eventName ) : Boolean
检测对象是否有指定事件的监听者. Checks to see if this object has any listeners fo...
检测对象是否有指定事件的监听者.

Checks to see if this object has any listeners for a specified event

参数:
 
eventName : String
要检查事件的名字.

The name of the event to check for

返回值:
 
Boolean
True if the event is being listened for, else false Observable
  indexOf (  Object o ) : Number
返回在集合中已通过的对象的索引. Returns index within the collection of the passed...
返回在集合中已通过的对象的索引.

Returns index within the collection of the passed Object.

参数:
 
o : Object
要找的索引项.

The item to find the index of.

返回值:
 
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.

参数:
 
key : String
要找索引的键值

The key to find the index of.

返回值:
 
Number
键值的索引.

index of the key.
 MixedCollection
  insert (  Number index, String key, Object o ) : Object
在集合中指定索引插入一项.当结束时,引发 add事件. Inserts an item at the spe...
在集合中指定索引插入一项.当结束时,引发 add事件.

Inserts an item at the specified index in the collection. Fires the add event when complete.

参数:
 
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.
 MixedCollection
  item (  String/Number key ) : Object
返回跟键值或索引相关连的项.键值比索引优先。这就是说先调用key,如果...
返回跟键值或索引相关连的项.键值比索引优先。这就是说先调用key,如果没有能匹配的就调用itemAt.

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.

参数:
 
key : String/Number
项的键值或索引

The key or index of the item.

返回值:
 
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.

参数:
 
index : Number
项的索引。

The index of the item.

返回值:
 
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.

参数:
 
key : String/Number
项的键值。

The key of the item.

返回值:
 
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

参数:
 
direction : String
"ASC"(升序)或“DESC”(降序)

"ASC" or "DESC"

fn : Function
一个比较函数(默认大小写不敏感)

a comparison function (defaults to case insensitive string)

返回值:
 
void  MixedCollection
  last (   ) : Object
返回集合的最后一项. Returns the last item in the collection.
返回集合的最后一项.

Returns the last item in the collection.

返回值:
 
Object
集合的最后一项.

the last item in the collection..
 MixedCollection
  on (  String eventName, Function handler, Object scope, Object options ) : void
添加一个事件处理函数到元素(addListender的简写) Appends an event handler to t...
添加一个事件处理函数到元素(addListender的简写)

Appends an event handler to this element (shorthand for addListener)

参数:
 
eventName : String
要监听的事件的类型

The type of event to listen for

handler : Function
事件调用的方法

The method the event invokes

scope : Object
执行处理函数的范围。处理函数的“this”上下文.

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

options : Object
返回值:
 
void  Observable
  purgeListeners (   ) : void
清楚这个对象的所有监听器 Removes all listeners for this object
清楚这个对象的所有监听器

Removes all listeners for this object

返回值:
 
void  Observable
  relayEvents (  Object o, Array events ) : void
从指定观察者接替已选择的事件就像这个事件被this触发。 Relays selected eve...
从指定观察者接替已选择的事件就像这个事件被this触发。

Relays selected events from the specified Observable as if the events were fired by this.

参数:
 
o : Object
要接替观察者的事件对象

The Observable whose events this object is to relay.

events : Array
 一组要被接替的事件名.

Array of event names to relay.

返回值:
 
void  Observable
  remove (  Object o ) : Object
删除集合中的一项. Remove an item from the collection. ...
删除集合中的一项.

Remove an item from the collection.

参数:
 
o : Object
要删除的项。

The item to remove.

返回值:
 
Object
删除了的项或是false如果没有项被删除。

The item removed or false if no item was removed.
 MixedCollection
  removeAt (  Number index ) : Object
在集合中删除指定索引项。当结束时触发remove事件。 Remove an item from a spec...
在集合中删除指定索引项。当结束时触发remove事件。

Remove an item from a specified index in the collection. Fires the remove event when complete.

参数:
 
index : Number
将被删除项在集合中的索引。

The index within the collection of the item to remove.

返回值:
 
Object
已删除的项或是false如果没有项被删除。

The item removed or false if no item was removed.
 MixedCollection
  removeKey (  String key ) : Object
删除在集合中,某一项相关联的键值。 Removed an item associated with the passed k...
删除在集合中,某一项相关联的键值。

Removed an item associated with the passed key fom the collection.

参数:
 
key : String
将要删除的某一项的键值。

The key of the item to remove.

返回值:
 
Object
以删除的项或是false如果没有一项被删除。

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

参数:
 
eventName : String
监听的事件类型。

The type of event to listen for

handler : Function
要删除的句柄。

The handler to remove

scope : Object
句柄的范围。

The scope (this object) for the handler

返回值:
 
void  Observable
  replace (  String key, o {Object} ) : Object
取代集合中的一项。当结束时触发replace事件。 Replaces an item in the collection...
取代集合中的一项。当结束时触发replace事件。

Replaces an item in the collection. Fires the replace event when complete.

参数:
 
key : String
要被替代项的键值,或是替代项。

如果你提供MixedCollection getKey方法的实现,或如果你存储项的键值在一个叫做id的属性,那MixedCollection 将会取到要替代项的键值。如果你想替代有相同键值的项,只要传递要替代的项在这个参数里。

The key associated with the item to replace, or the replacement item.

If you supplied a getKey implementation for this MixedCollection, or if the key of your stored items is in a property called id, then the MixedCollection will be able to derive the key of the replacement item. If you want to replace an item with one having the same key value, then just pass the replacement item in this parameter.

{Object} : o
o如果第一个参数传递的是一个键值,那么这项与键值相关联。

o (optional) If the first parameter passed was a key, the item to associate with that key.

返回值:
 
Object
The new item. MixedCollection
  resumeEvents (   ) : void
重新触发事件。(看suspendEvents) Resume firing events. (see suspendEvents)
重新触发事件。(看suspendEvents)

Resume firing events. (see suspendEvents)

返回值:
 
void  Observable
  sort (  String direction, Function fn ) : void
用传递过来的比较函数对集合排序。 Sorts this collection with the passed compariso...
用传递过来的比较函数对集合排序。

Sorts this collection with the passed comparison function

参数:
 
direction : String
"ASC" or "DESC"
fn : Function
comparison function
返回值:
 
void  MixedCollection
  suspendEvents (   ) : void
暂停所有事件的触发。 Suspend the firing of all events. (see resumeEvents)
暂停所有事件的触发。

Suspend the firing of all events. (see resumeEvents)

返回值:
 
void  Observable
  un (  String eventName, Function handler, Object scope ) : void
删除一个监听者。(shorthand for removeListener) Removes a listener (shorthand for rem...
删除一个监听者。(shorthand for removeListener)

Removes a listener (shorthand for removeListener)

参数:
 
eventName : String
The type of event to listen for
handler : Function
要删除的句柄。

The handler to remove

scope : Object
The scope (this object) for the handler
返回值:
 
void  Observable
已公开的事件事件 继承自
  add(  Number index, Object o, String key )
当一项被添加到集合时触发。 Fires when an item is added to the collection.
侦听器将得到以下参数:
 
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.  MixedCollection
  remove(  Object o, String key )
当一项从集合中删除时触发。 Fires when an item is removed from the collection.
侦听器将得到以下参数:
 
o : Object
The item being removed.
key : String
The key associated with the removed item. MixedCollection
  replace(  String key, Object old, Object new )
当一项被替代时触发。 Fires when an item is replaced in the collection.
侦听器将得到以下参数:
 
key : String
he key associated with the new added.
old : Object
The item being replaced.
new : Object
The new item. MixedCollection

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值