| |
add
(
String key,
Object o
)
: Object
加入一个item到集合中。
加入一个item到集合中。
参数项:
key : String
item的键名称
o : Object
加入的item
返回:
|
MixedCollection
|
| |
getKey
(
*/
)
: Object
如果你执行getKey的方法,MixedCollection有一个通用...
如果你执行getKey的方法,MixedCollection有一个通用的方法来取得keys。
默认的实现只是简单地返回 item.id,
不过你可以按照下面的例子自定义一个实现,以返回另外一个值
// 一般方式
var mc = new Ext.util.MixedCollection();
mc.add(someEl.dom.id, someEl);
mc.add(otherEl.dom.id, otherEl);
//等等
// 使用getKey
var mc = new Ext.util.MixedCollection();
mc.getKey = function(el){
return el.dom.id;
};
mc.add(someEl);
mc.add(otherEl);
// 或通过构造器
var mc = new Ext.util.MixedCollection(false, function(el){
return el.dom.id;
});
mc.add(someEl);
mc.add(otherEl);
|
MixedCollection
|
| |
replace
(
String key,
)
: Object
替换集合中的item。完成后触发{@link #replace}事件。
替换集合中的item。完成后触发{@link #replace}事件。
|
MixedCollection
|
| |
addAll
(
Object/Array objs
)
|
MixedCollection
|
| |
each
(
Function fn,
Object scope
)
在集合中执行每个Item的指定函数。函数执行时,会有下列的参数:
<...
在集合中执行每个Item的指定函数。函数执行时,会有下列的参数:
- item : Mixed
集合中的item
- index : Number
item的索引
- length : Number
集合中的items的总数
那个函数应该要返回一个布尔值。若函数返回false便终止枚举。
参数项:
fn : Function
每个item要执行的函数
scope : Object
(optional) 函数执行时的作用域
返回:
|
MixedCollection
|
| |
eachKey
(
Function fn,
[Object scope]
)
传入一个函数类型的参数,然后在集合中的每个Item执行。key和其相关...
传入一个函数类型的参数,然后在集合中的每个Item执行。key和其相关的item都作为头两个参数传入。
参数项:
fn : Function
每个item要执行的函数。
scope : Object
(可选的)执行函数的作用域
返回:
|
MixedCollection
|
| |
find
(
Function fn,
[Object scope]
)
: Object
根据传入的函数,执行该函数若返回true便说明这是要找到的那个item。
根据传入的函数,执行该函数若返回true便说明这是要找到的那个item。
参数项:
fn : Function
每个item要执行的查询函数。
scope : Object
(可选的)执行函数的作用域
返回:
Object 根据规则函数在集合中第一个找到的item
|
MixedCollection
|
| |
insert
(
Number index,
String key,
[Object o]
)
: Object
指定集合中的某个索引然后插入一个Item
指定集合中的某个索引然后插入一个Item
参数项:
index : Number
要插入item的索引。
key : String
包含新item的key名称,或item本身
o : Object
(可选的) 如果第二个参数是key,新item
返回:
|
MixedCollection
|
| |
remove
(
Object o
)
: Object
|
MixedCollection
|
| |
removeAt
(
Number index
)
: Object
从集合中移除由index指定的Item。完成后触发{@link #re...
从集合中移除由index指定的Item。完成后触发{@link #remove}事件。
参数项:
返回:
Object 被移除的item或是false就代表没有移除。
|
MixedCollection
|
| |
removeKey
(
String key
)
: Object
根据传入参数key,从集合中移除相关的item
根据传入参数key,从集合中移除相关的item
参数项:
返回:
Object 被移除的item或是false就代表没有移除。
|
MixedCollection
|
| |
getCount
(
)
: Number
|
MixedCollection
|
| |
indexOf
(
Object o
)
: Number
|
MixedCollection
|
| |
indexOfKey
(
String key
)
: Number
|
MixedCollection
|
| |
item
(
String/Number key
)
: Object
根据key或索引(index)返回item。key的优先权高于索引。
...
根据key或索引(index)返回item。key的优先权高于索引。
这个方法相当于先调用{@link #key},如不匹配在调用{@link #itemAt}。
参数项:
key : String/Number
或者是item的索引
返回:
|
MixedCollection
|
| |
itemAt
(
Number index
)
: Object
根据索引找到item
根据索引找到item
参数项:
index : Number
item的索引index
返回:
|
MixedCollection
|
| |
key
(
String/Number key
)
: Object
根据key找到item
根据key找到item
参数项:
key : String/Number
item的key
返回:
|
MixedCollection
|
| |
contains
(
Object o
)
: Boolean
若在集合中找到传入的item,则返回true。
若在集合中找到传入的item,则返回true。
参数项:
返回:
Boolean True表示为在集合中找到该item
|
MixedCollection
|
| |
containsKey
(
Object o
)
: Boolean
若在集合中找到传入的key,则返回true。
若在集合中找到传入的key,则返回true。
参数项:
返回:
Boolean True表示为在集合中找到该key
|
MixedCollection
|
| |
clear
(
)
|
MixedCollection
|
| |
first
(
)
: Object
|
MixedCollection
|
| |
last
(
)
: Object
|
MixedCollection
|
| |
sort
(
[*/ ],
[Function fn]
)
|
MixedCollection
|
| |
keySort
(
[*/ ],
[Function fn]
)
|
MixedCollection
|
| |
getRange
(
[Number startIndex],
[Number endIndex]
)
: Array
返回这个集合中的某个范围内的items
返回这个集合中的某个范围内的items
参数项:
startIndex : Number
(可选的) 默认为 0
endIndex : Number
(可选的) 默认为最后的item
返回:
|
MixedCollection
|
| |
filter
(
String property,
String/RegExp value,
Boolean anyMatch,
Boolean caseSensitive
)
: MixedCollection
由指定的属性过滤集合中的对象。
返回以过滤后的新集合
由指定的属性过滤集合中的 对象。
返回以过滤后的新集合
参数项:
property : String
你对象身上的属性
value : String/RegExp
也可以是属性开始的值或对于这个属性的正则表达式
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).
返回:
|
MixedCollection
|
| |
filterBy
(
Function fn,
[Object scope]
)
: MixedCollection
由函数过滤集合中的 对象。
返回以过滤后的 新
由函数过滤集合中的 对象。
返回以过滤后的 新集合
传入的函数会被集合中每个对象执行。如果函数返回true,则value会被包含否则会被过滤、
|
MixedCollection
|
| |
findIndex
(
String property,
String/RegExp value,
[Number start],
[Boolean anyMatch],
[Boolean caseSensitive]
)
: Number
由指定的属性/值查找集合中的第一个匹配对象。
这个对象是过滤后的
由指定的属性/值查找集合中的第一个匹配对象。
这个对象是过滤后的 新集合
|
MixedCollection
|
| |
findIndexBy
(
Function fn,
[Object scope],
[Number start]
)
: MixedCollection
由函数过滤集合中的 对象。
返回以过滤后的 新
由函数过滤集合中的 对象。
返回以过滤后的 新集合
传入的函数会被集合中每个对象执行。如果函数返回true,则value会被包含否则会被过滤、
|
MixedCollection
|
| |
clone
(
)
: MixedCollection
|
MixedCollection
|
| |
Ext.util.MixedCollection.prototype.get
(
String/Number key
)
: Object
根据key或索引返回item。key的优先权高于索引。
@method
根据key或索引返回item。key的优先权高于索引。
@method
参数项:
key : String/Number
或者是item的索引
返回:
|
MixedCollection
|