Hierarchy
Ext.BaseExt.util.AbstractMixedCollectionExt.util.MixedCollectionExt.form.CheckboxManagerInherited mixins
Files
NOTE This is a private utility class for internal use by the framework. Don't rely on its existence.
私有的工具类, 根据name对所有的 Ext.form.field.Checkbox 输入框分组.
指定为 true
则表示 addAll
函数将添加函数引用到集合中. 默认值:
false
.
Defaults to: false
一个配置对象,包含一个或多个事件处理函数,在对象初始化时添加到对象。 它应该是addListener指定的一个有效的监听器配置对象, 一次添加多个事件处理函数。
Ext JS 组建的DOM事件
虽然一些Ext JS组件类输出选定的DOM事件(例如"click"、"mouseover"等),
但是这只能通过添加额外的值(如果能)。例如,DataView的itemclick
传递被单击的节点。为了通过Component的子元素直接访问DOM事件,
我们需要指定element
选项来标识要
添加DOM监听器的Component属性:
new Ext.panel.Panel({
width: 400,
height: 200,
dockedItems: [{
xtype: 'toolbar'
}],
listeners: {
click: {
element: 'el', //bind to the underlying el property on the panel
fn: function(){ console.log('click el'); }
},
dblclick: {
element: 'body', //bind to the underlying body property on the panel
fn: function(){ console.log('dblclick body'); }
}
}
});
扩展事件
Defaults to: []
默认的排序方向
Defaults to: "ASC"
用于添加和删除时候递增的变化计数器.
Defaults to: 0
本对象包含任何有监听器的事件的键。监听器可以在实例上直接设置, 或者在其类或者父类(通过observe) 或者在MVC EventBus上设置。本对象的值为真 (一个非零的数字)和假(0或者undefined)。它们并不代表确切的监听器数量。 如果事件必须被触发,它的值是真的, 如果没有必要,就是假的。
本属性的设计目的是避免没有监听器时调用fireEvent的开销。 如果fireEvent要调用成百上千次,这尤其有用。 用法:
if (this.hasListeners.foo) {
this.fireEvent('foo', this, arg1);
}
在此类对象中, 如果是true
,标识一个对象是 MixedCollection 的实例,还是他的子类的实例.
Defaults to: true
在本类中设置为true
将一个对象标识为实例化的Observable或其子类。
Defaults to: true
设置为true
将某个对象标识为实例化的Sortable或其子类。
Defaults to: true
本身
获取当前类的引用,此对象被实例化。不同于 statics,
this.self
是依赖范围,它意味着要使用动态继承。
参见 statics 详细对比
Ext.define('My.Cat', {
statics: {
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
alert(this.self.speciesName); // 依赖 'this'
},
clone: function() {
return new this.self();
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
}
});
var cat = new My.Cat(); // alerts 'Cat' 猫
var snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard' 雪豹
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
Performs the actual sorting based on a direction and a sorting function. Internally, this creates a temporary array of all items in the MixedCollection, sorts it and then writes the sorted array data back into this.items and this.keys
添加一个数组,或者对象的元素到集合中.
An Object containing properties which will be added
to the collection, or an Array of values, each of which are added to the collection.
Functions references will be added to the collection if allowFunctions
has been set to true
.
成员
向本对象添加一个事件处理函数,例如:
myGridPanel.on("mouseover", this.onMouseOver, this);
这个方法也允许传递单个参数,参数为一个 包含指定多个事件的属性的配置对象。例如:
myGridPanel.on({
cellClick: this.onCellClick,
mouseover: this.onMouseOver,
mouseout: this.onMouseOut,
scope: this // Important. Ensure "this" is correct during handler execution
});
你也能为每个事件处理函数单独指定选项:
myGridPanel.on({
cellClick: {fn: this.onCellClick, scope: this, single: true},
mouseover: {fn: panel.onMouseOver, scope: panel}
});
也能使用在特定作用域的方法名。注意
必须指定scope
:
myGridPanel.on({
cellClick: {fn: 'onCellClick', scope: this, single: true},
mouseover: {fn: 'onMouseOver', scope: panel}
});
被监听的事件名。 也可以是属性名字是事件名字的对象。
事件调用的方法, 或者如果指定了scope
,在指定scope
的方法名*。
会被调用,
参数为fireEvent的参数加上下述options
参数。
事件处理函数执行的作用域(this
应用的上下文)
如果省略, 默认为触发事件的对象。
包含事件处理函数配置的对象。
注意: 不像ExtJS 3.x, options对象也会作为最后一个参数 传递给每一个事件处理函数。
这个对象可能包含以下任何一个属性:
事件处理函数执行的作用域(this
应用的上下文)
如果省略, 默认为触发事件的对象。
事件触发后,调用事件处理函数延时毫秒数。
设置为true添加一个事件处理函数,只处理下一次触发的事件, 然后移除这个函数。
使事件处理函数在Ext.util.DelayedTask中调度运行, 延时指定的毫秒数。如果事件在这段事件再次触发, 原先的事件处理函数不再调用, 新的事件处理函数接替。
只有当事件在目标Observable上触发时调用事件处理函数, 如果事件是从Observable的子类起泡的,不会调用事件处理函数
这个选项只对绑定在Components上的监听器有效。 Component的一个属性名,这个属性引用一个待添加监听器的元素
这个选项在Component构造过程中向Components的元素添加DOM事件监听器有用。 这些元素只有在Component渲染之后才会存在。 例如, 向Panel的body中添加click监听器:
new Ext.panel.Panel({
title: 'The title',
listeners: {
click: this.handlePanelClick,
element: 'body'
}
});
组合选项
使用options参数, 可以组合不同类型的监听器:
一个延时的一次性监听器:
myPanel.on('hide', this.handleClick, this, {
single: true,
delay: 100
});
向任何Observable对象(或者Ext.Element)添加监听器, 当组件被销毁时,监听器自动被移除
添加监听器的目标项。
事件名或者包含的事件名属性的对象。
(可选的) 如果ename
参数是事件名, 这就是一个事件处理函数。
(可选的) 如果ename
参数是事件名, 这就是(this
引用的上下文)
事件处理函数执行的作用域。
(可选的)如果ename
参数是事件名,
这就是addListener的选项。
调用原来的方法,这是以前的override重写
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
this.callOverridden();
alert("Meeeeoooowwww");
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
This method has been deprecated since 4.1
版本 使用 callParent 代替.
参数的参数,数组或'参数'对象
来自当前方法,例如: this.callOverridden(arguments)
返回调用重写方法的结果。
所谓的"parent"方法是指当前的方法。 这是以前的方法派生或重写(参见 Ext.define)。
Ext.define('My.Base', {
constructor: function (x) {
this.x = x;
},
statics: {
method: function (x) {
return x;
}
}
});
Ext.define('My.Derived', {
extend: 'My.Base',
constructor: function () {
this.callParent([21]);
}
});
var obj = new My.Derived();
alert(obj.x); // alerts 21
这可以用来重写如下:
Ext.define('My.DerivedOverride', {
override: 'My.Derived',
constructor: function (x) {
this.callParent([x*2]); // 调用原来的My.Derived构造
}
});
var obj = new My.Derived();
alert(obj.x); // 现在提示 42
This also works with static methods.
Ext.define('My.Derived2', {
extend: 'My.Base',
statics: {
method: function (x) {
return this.callParent([x*2]); // 调用 My.Base.method
}
}
});
alert(My.Base.method(10); // alerts 10
alert(My.Derived2.method(10); // alerts 20
然后,它也可以重写静态方法。
Ext.define('My.Derived2Override', {
override: 'My.Derived2',
statics: {
method: function (x) {
return this.callParent([x*2]); // 调用 My.Derived2.method
}
}
});
alert(My.Derived2.method(10); // 现在提示 40
这个参数, 通过当前方法得到数组或者 arguments
对象,
例如: this.callParent(arguments)
返回调用父类的方法的结果。
移除本对象的包括受管理的监听器在内的所有监听器
移除本对象的所有受管理的监听器
Collects unique values of a particular property in this MixedCollection
The property to collect on
'root' property to extract the first argument from. This is used mainly when summing fields in records, where the fields are all stored inside the 'data' object
Pass true to allow null, undefined or empty string values
The unique values
Returns a regular expression based on the given value and matching options. This is used internally for finding and filtering, and by Ext.data.Store.filter
The value to create the regex for. This is escaped using Ext.escapeRe
True to allow any match - no regex start/end line anchors will be added. Defaults to false
True to make the regex case sensitive (adds 'i' switch to regex). Defaults to false.
True to force exact match (^ and $ characters added to the regex). Defaults to false. Ignored if anyMatch is true.
Normalizes an array of sorter objects, ensuring that they are all Ext.util.Sorter instances
The sorters array
Array of Ext.util.Sorter objects
遍历集合,并用每一个item作为参数,执行指定的函数, passing the following arguments:
The collection item
The item's index
The total number of items in the collection
The function should return a boolean value. Returning false from the function will stop the iteration.
Executes the specified function once for every key in the collection, passing each key, and its associated item as the first two parameters.
通过调用this.getBubbleTarget()
(如果存在)允许本Observable对象触发的事件沿着继承体系起泡
在Observable基类中没有实现类。
这通常被Ext.Components用来将事件起泡到它的容器。 见Ext.Component.getBubbleTarget。Ext.Component中的默认实现 返回Component的直接容器。但是如果需要一个明显的target, 它可以被重写 以更快地访问需要的target。
使用范例:
Ext.override(Ext.form.field.Base, {
// Add functionality to Field's initComponent to enable the change event to bubble
initComponent : Ext.Function.createSequence(Ext.form.field.Base.prototype.initComponent, function() {
this.enableBubble('change');
}),
// We know that we want Field's events to bubble directly to the FormPanel.
getBubbleTarget : function() {
if (!this.formPanel) {
this.formPanel = this.findParentByType('form');
}
return this.formPanel;
}
});
var myForm = new Ext.formPanel({
title: 'User Details',
items: [{
...
}],
listeners: {
change: function() {
// Title goes red if form has been modified.
myForm.header.setStyle('color', 'red');
}
}
});
Extracts all of the given property values from the items in the MC. Mainly used as a supporting method for functions like sum and collect.
The property to extract
'root' property to extract the first argument from. This is used mainly when extracting field data from Model instances, where the fields are stored inside the 'data' object
The extracted values
Filters the objects in this collection by a set of Filters, or by a single property/value pair with optional parameters for substring matching and case sensitivity. See Filter for an example of using Filter objects (preferred). Alternatively, MixedCollection can be easily filtered by property like this:
//create a simple store with a few people defined
var people = new Ext.util.MixedCollection();
people.addAll([
{id: 1, age: 25, name: 'Ed'},
{id: 2, age: 24, name: 'Tommy'},
{id: 3, age: 24, name: 'Arne'},
{id: 4, age: 26, name: 'Aaron'}
]);
//a new MixedCollection containing only the items where age == 24
var middleAged = people.filter('age', 24);
A property on your objects, or an array of Filter objects
Either string that the property values should start with or a RegExp to test against the property
True to match any part of the string, not just the beginning
Defaults to: false
True for case sensitive comparison.
Defaults to: false
The new filtered collection
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.
The function to be called, it will receive the args o (the object), k (the key)
The scope (this
reference) in which the function is executed. Defaults to this MixedCollection.
The new filtered collection
Returns the first item in the collection which elicits a true return value from the passed selection function.
The selection function to execute for each item.
The scope (this
reference) in which the function is executed. Defaults to the browser window.
The first item in the collection which returned true from the selection function, or null if none was found
Finds the index of the first matching object in this collection by a specific property/value.
The name of a property on your objects.
A string that the property values should start with or a RegExp to test against the property.
The index to start searching at.
Defaults to: 0
True to match any part of the string, not just the beginning.
Defaults to: false
True for case sensitive comparison.
Defaults to: false
The matched index or -1
Find the index of the first matching object in this collection by a function. If the function returns true it is considered a match.
The function to be called, it will receive the args o (the object), k (the key).
The scope (this
reference) in which the function is executed. Defaults to this MixedCollection.
The index to start searching at.
Defaults to: 0
The matched index or -1
使用传递过来的参数(去掉事件名,加上传递给addListener的options
对象
)触发指定的事件。
通过调用enableBubble,一个事件 能被设置为沿着Observable的继承体系(见Ext.Component.getBubbleTarget)向上起泡。
如果任何一个事件处理函数返回false,就返回false,否则返回true。
Returns the item associated with the passed key OR index. Key has priority over index. This is the equivalent of calling getByKey first, then if nothing matched calling getAt.
If the item is found, returns the item. If the item was not found, returns undefined
.
If an item was found, but is a Class, returns null
.
Gets the bubbling parent for an Observable
The bubble parent. null is returned if no bubble target exists
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);
The item for which to find the key.
The key for the passed item.
这个类的初始化配置。典型例子:
Ext.define('My.awesome.Class', {
// 这是默认配置
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome' 超级棒
配置
mixins 混入原型 键-值对
初始化本混入元素。使用本混入元素的组件类 应该在它们初始化时调用这个方法。
Inserts an item at the specified index in the collection. Fires the add event when complete.
The index to insert the item at.
The key to associate with the new item, or the item itself.
If the second parameter was a key, the new item.
The item inserted.
addManagedListener的简写方法
向任何Observable对象(或者Ext.Element)添加监听器, 当组件被销毁时,监听器自动被移除
添加监听器的目标项。
事件名或者包含的事件名属性的对象。
(可选的) 如果ename
参数是事件名, 这就是一个事件处理函数。
(可选的) 如果ename
参数是事件名, 这就是(this
引用的上下文)
事件处理函数执行的作用域。
(可选的)如果ename
参数是事件名,
这就是addListener的选项。
移除通过mon方法添加的监听器。
待移除监听器的项
事件名或者包含的事件名属性的对象。
(可选的) 如果ename
参数是事件名, 这就是一个事件处理函数。
(可选的) 如果ename
参数是事件名, 这就是(this
引用的上下文)
事件处理函数执行的作用域。
addListener的简写方法
向本对象添加一个事件处理函数,例如:
myGridPanel.on("mouseover", this.onMouseOver, this);
这个方法也允许传递单个参数,参数为一个 包含指定多个事件的属性的配置对象。例如:
myGridPanel.on({
cellClick: this.onCellClick,
mouseover: this.onMouseOver,
mouseout: this.onMouseOut,
scope: this // Important. Ensure "this" is correct during handler execution
});
你也能为每个事件处理函数单独指定选项:
myGridPanel.on({
cellClick: {fn: this.onCellClick, scope: this, single: true},
mouseover: {fn: panel.onMouseOver, scope: panel}
});
也能使用在特定作用域的方法名。注意
必须指定scope
:
myGridPanel.on({
cellClick: {fn: 'onCellClick', scope: this, single: true},
mouseover: {fn: 'onMouseOver', scope: panel}
});
被监听的事件名。 也可以是属性名字是事件名字的对象。
事件调用的方法, 或者如果指定了scope
,在指定scope
的方法名*。
会被调用,
参数为fireEvent的参数加上下述options
参数。
事件处理函数执行的作用域(this
应用的上下文)
如果省略, 默认为触发事件的对象。
包含事件处理函数配置的对象。
注意: 不像ExtJS 3.x, options对象也会作为最后一个参数 传递给每一个事件处理函数。
这个对象可能包含以下任何一个属性:
事件处理函数执行的作用域(this
应用的上下文)
如果省略, 默认为触发事件的对象。
事件触发后,调用事件处理函数延时毫秒数。
设置为true添加一个事件处理函数,只处理下一次触发的事件, 然后移除这个函数。
使事件处理函数在Ext.util.DelayedTask中调度运行, 延时指定的毫秒数。如果事件在这段事件再次触发, 原先的事件处理函数不再调用, 新的事件处理函数接替。
只有当事件在目标Observable上触发时调用事件处理函数, 如果事件是从Observable的子类起泡的,不会调用事件处理函数
这个选项只对绑定在Components上的监听器有效。 Component的一个属性名,这个属性引用一个待添加监听器的元素
这个选项在Component构造过程中向Components的元素添加DOM事件监听器有用。 这些元素只有在Component渲染之后才会存在。 例如, 向Panel的body中添加click监听器:
new Ext.panel.Panel({
title: 'The title',
listeners: {
click: this.handlePanelClick,
element: 'body'
}
});
组合选项
使用options参数, 可以组合不同类型的监听器:
一个延时的一次性监听器:
myPanel.on('hide', this.handleClick, this, {
single: true,
delay: 100
});
从指定的Observable接替选定的事件就好像事件是this
触发的。
例如,如果你想要扩展Grid, 你可能决定转发store的一些事件。 所以你能在你的initComponent中实现这个:
this.relayEvents(this.getStore(), ['load']);
grid实例将会有一个observable的'load'事件,
这个事件的参数是store的load事件的参数。任何grid的load事件触发的函数
可以使用this
访问grid。
Remove all items in the passed array from the collection.
An array of items to be removed.
this object
移除事件处理函数。
事件处理函数关联的事件类型
待移除的事件处理函数。 必须是对传递给addListener 的函数的引用。
(可选的) 原先为事件处理函数指定的作用域。 它必须是和原先调用addListener时指定的作用域参数是一样的,否者监听器将会被移除。
移除通过mon方法添加的监听器。
待移除监听器的项
事件名或者包含的事件名属性的对象。
(可选的) 如果ename
参数是事件名, 这就是一个事件处理函数。
(可选的) 如果ename
参数是事件名, 这就是(this
引用的上下文)
事件处理函数执行的作用域。
替换集合中的对象. Fires the replace event when complete.
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 (optional) If the first parameter passed was a key, the item to associate with that key.
The new item.
继续事件的触发(见suspendEvents)。
如果事件被使用queueSuspended
参数挂起, 那么所有
在事件挂起期间触发的事件将会被发送到任意监听器。
使用一个或多个排序Store中的数据。使用范例:
//sort by a single field
myStore.sort('myField', 'DESC');
//sorting by multiple fields
myStore.sort([
{
property : 'age',
direction: 'ASC'
},
{
property : 'name',
direction: 'DESC'
}
]);
Store在内部将参数转换为Ext.util.Sorter实例数组, 把实际的排序过程委托给它内部的Ext.util.MixedCollection。
当传递单个字符串参数时, Store给每一个字段保存了一个ASC/DESC切换器,所以如下代码:
store.sort('myField');
store.sort('myField');
等价于如下代码, 因为Store实现自动的切换:
store.sort('myField', 'ASC');
store.sort('myField', 'DESC');
本Store的配置的Model的一个字段的字符串名字, 或者排序器配置数组。
数据排序方向。默认为"ASC"。
获取从该对象被实例化的类的引用。 请注意不同于 self,
this.statics()
是独立的作用域,无论this
是否运行,总是返回其中的调用类。
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // 总是等于'Cat',无论'this'是什么,
// 相当于:My.Cat.speciesName
alert(this.self.speciesName); // 依赖 'this'
statics.totalCreated++;
},
clone: function() {
var cloned = new this.self; // 依赖 'this'
cloned.groupName = this.statics().speciesName; // 相当于: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', 然后提示 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', 然后提示 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Collects all of the values of the given property and returns their sum
The property to sum by
'root' property to extract the first argument from. This is used mainly when summing fields in records, where the fields are all stored inside the 'data' object
The record index to start at
Defaults to: 0
The record index to end at
Defaults to: -1
The total
挂起所有事件的触发。(见resumeEvents)
传true,让挂起的事件排队而不是丢弃所有挂起的事件, 这些事件将会在调用resumeEvents之后触发。
配置扩展
removeListener的简写方法
移除事件处理函数。
事件处理函数关联的事件类型
待移除的事件处理函数。 必须是对传递给addListener 的函数的引用。
(可选的) 原先为事件处理函数指定的作用域。 它必须是和原先调用addListener时指定的作用域参数是一样的,否者监听器将会被移除。
当添加一个项到 集合中时触发.
项目被添加后的索引.
添加的项目.
关联所添加项目的key.
The options object passed to Ext.util.Observable.addListener.
当一个项在集合中被移除时触发.
被移除的项目.
(optional,可选) 关联所移除项目的key.
The options object passed to Ext.util.Observable.addListener.