Hierarchy
Ext.BaseExt.util.AbstractMixedCollectionExt.util.MixedCollectionExt.draw.CompositeSpriteExt.chart.LegendItemInherited mixins
Requires
Files
图例的一个单独的条目
指定为 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的选项。
在 this 这个对象上执行自定义动画.
动画方法适用于 Component 类和 Element 类. 它在指定的时间内,对this对象的特定属性进行动画.
唯一的参数是一个配置对象, 该对象定义了开始属性值, 结束属性值,以及描述时间线的属性.
当一个元素进行动画时, 下列的属性都可定义在 from
, to
, 以及 keyframe
这几个配置对象中:
x
- 页面 X 位置,单位:像素.
y
- 页面 Y 位置,单位:像素.
left
- 元素的 CSS left
值. 必须指定单位(比如: "6px").
top
- 元素的 CSS top
值. 必须指定单位(比如: "6px").
width
- 元素的 CSS width
值. 必须指定单位(比如: "6px").
height
- 元素的 CSS height
值. 必须指定单位(比如: "6px").
scrollLeft
- 元素的 scrollLeft
值.
scrollTop
- 元素的 scrollLeft
值.
opacity
- 元素的 opacity
值. 透明度,值只能位于 0
和 1
之间.
需要注意的是, 如果动画一个被 Ext Component 所使用的元素,却不以某种方式通知组件Component 元素改变过后的状态, 可能会导致错误的 Component 行为. 这是因为 Component会继续使用元素旧的状态. 想要规避这个问题, 直接对Components 特定的属性值进行动画即可(而不要动画其内部的元素).
当组件进行动画的时候, 下列的属性都可定义在 from
, to
, and keyframe
这几个配置对象中:
x
- 组件在页面内的 X 位置,单位:像素.
y
- 组件在页面内的 Y 位置,单位:像素.
left
- 组件的 left
值,单位:像素.
top
- 组件的 top
值,单位:像素.
width
- 组件的 width
值,单位:像素.
height
- 组件的 height
值,单位:像素.
dynamic
- 指定为 true, 则动画的每一帧都会 更新组件的布局 (如果是容器的话).
需要注意,每次组件大小改变,立即就重新进行布局是一种昂贵的操作.请根据实际需要进行取舍
要将一个 Window 通过动画效果改变大小, 确保其内部的布局,以及所有的阴影都正确,代码如下:
myWindow = Ext.create('Ext.window.Window', {
title: 'Test Component animation',
width: 500,
height: 300,
layout: {
type: 'hbox',
align: 'stretch'
},
items: [{
title: 'Left: 33%',
margins: '5 0 5 5',
flex: 1
}, {
title: 'Left: 66%',
margins: '5 5 5 5',
flex: 2
}]
});
myWindow.show();
myWindow.header.el.on('click', function() {
myWindow.animate({
to: {
width: (myWindow.getWidth() == 500) ? 700 : 500,
height: (myWindow.getHeight() == 300) ? 400 : 300,
}
});
});
基于效率和性能的考虑, 默认情况下, Window 的内部布局只在其达到 "to"
所指定的大小时才进行刷新.
如果需要动态更新 Window 的子组件, 可以指定动画的属性 dynamic: true
,
此时两个子item在动画过程中都保持其比例.
一个对象,包含动画相关的属性,这些属性包括: 指定起始状态,结束状态,以及动画的时间线 相关的值.
下面所列出的属性中,只有 to
是强制必须有的.
config的属性值包括:
一个对象,指定动画开始时的相关CSS属性值. 如果没有指定,则默认使用元素当前实际的值. 实际的属性可能受此对象前面的动画所影响. 参见下面的元素与组件动画小节.
一个对象,指定动画结束时需要达到的相关CSS属性值.
每次动画的持续时间,单位: 毫秒 milliseconds.
一个字符串值.用于描述 如何从默认的线下 变为 非线性 的速率的类型. 其值 可以 是下列英文字符串 之一:
关键帧; 此参数是一个描述在时间轴(时间线)中特定点动作属性的对象. 其包含的属性, 名称是时间轴百分比的数字,对应的值指定在这个点的动画状态.
这是一个标准的 监听器 配置对象,
可用于在beforeanimate
事件 或者 afteranimate
事件中注入行为.
this
调用原来的方法,这是以前的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
销毁sprite组
遍历集合,并用每一个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.
返回此元素当前是否有正在进行或在队列中的动画效果, 没有则返回 false.
This method has been deprecated
废弃的方法; 4.0以后使用 getActiveAnimation 替代
如果元素有正在进行的动画效果则返回 true, 否则返回 false
隐藏所有的sprite. 如果方法的第一个参数为true, 会强制重绘每一个sprite.
是否立即重绘的标识. 设置为true,立即重绘.
这个类的初始化配置。典型例子:
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
参数挂起, 那么所有
在事件挂起期间触发的事件将会被发送到任意监听器。
显示所有的sprite. 如果方法的第一个参数为true, 会强制重绘每一个sprite.
是否立即重绘的标识. 设置为true,立即重绘.
使用一个或多个排序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
停止所有正在运行的特效,并清空此对象内部特效队列,如果此队列包含有尚未开始执行的那些特效.
This method has been deprecated
从 4.0 开始被 stopAnimation 替代
The Element
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时指定的作用域参数是一样的,否者监听器将会被移除。
更新图例中所有条目元件的位置,以使其可以与图例框的位置匹配
If specified, this object's 'x' and 'y' values will be used
as the reference point for the relative positioning. Defaults to the Legend.
方法/属性添加到这个类的原型。
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
成员
添加/重写这个类的静态属性。
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
成员
this
这个类的原型借用另一个类的成员
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
this 借用成员
创建这个类的新实例。
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
所有参数传递至类的构造。
创建的实例。
创建现有的原型方法的别名。例如:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
别名新方法的名称,或对象设置多个别名。 参见flexSetter
原来的方法名
以字符串格式,获取当前类的名称。
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
className 类名
重写这个类的成员。通过callParent重写的方法可以调用。
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.callParent(arguments);
alert("Meeeeoooowwww");
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!我要成为一只猫!"
// alerts "I'm a cat!我是一只猫!"
// alerts "Meeeeoooowwww"
在4.1版本, 直接利用这种方法已经过时了。 使用 Ext.define 代替:
Ext.define('My.CatOverride', {
override: 'My.Cat',
constructor: function() {
alert("I'm going to be a cat!");
this.callParent(arguments);
alert("Meeeeoooowwww");
}
});
以上完成了相同的结果,但可以由Ext.Loader重写, 其目标类和生成过程中,可以决定是否需要根据目标类所需的状态覆盖管理(My.Cat)。
This method has been deprecated since 4.1.0
使用 Ext.define 代替
添加到这个类的属性。 这应当被指定为一个对象包含一个或多个属性的文字。
this class 当前类
当添加一个项到 集合中时触发.
项目被添加后的索引.
添加的项目.
关联所添加项目的key.
The options object passed to Ext.util.Observable.addListener.
当一个项在集合中被移除时触发.
被移除的项目.
(optional,可选) 关联所移除项目的key.
The options object passed to Ext.util.Observable.addListener.