| Defined In: | Action.js |
| Class: | Ext.Action |
| Extends: | Object |
Action 是可复用性中可以抽象出来,被任意特定组件所继承的特性之一。 Action 使你可以通过所有实现了 Actions 接口的组件共享处理函数、配置选项对象以及 UI 的更新(比如 Ext.Toolbar、Ext.Button 和 Ext.menu.Menu 组件)。
除了提供的配置选项对象接口之外,任何想要使用 Action 的组件必需提供下列方法以便在 Action 所需时调用:setText(string)、setIconCls(string)、setDisabled(boolean)、setVisible(boolean)和setHandler(function)。
使用示例:
// Define the shared action. Each component below will have the same
// display text and icon, and will display the same message on click.
var action = new Ext.Action({
text: 'Do something',
handler: function(){
Ext.Msg.alert('Click', 'You did something.');
},
iconCls: 'do-something'
});
var panel = new Ext.Panel({
title: 'Actions',
width:500,
height:300,
tbar: [
// Add the action directly to a toolbar as a menu button
action, {
text: 'Action Menu',
// Add the action to a menu as a text item
menu: [action]
}
],
items: [
// Add the action to the panel body as a standard button
new Ext.Button(action)
],
renderTo: Ext.getBody()
});
// Change the text for all components using the action
action.setText('Something else');
| 配置项 | 定义者 | |
|---|---|---|
|
text
: String
使用 action 对象的所有组件的文本(默认为 '')。
使用 action 对象的所有组件的文本(默认为 '')。
|
Action | |
|
iconCls
: String
使用 action 对象的组件的图标样式表(默认为 '')。
...
使用 action 对象的组件的图标样式表(默认为 '')。
该样式类应该提供一个显示为图标的背景图片。
|
Action | |
|
disabled
: Boolean
true 则禁用组件,false 则启用组件(默认为 false)。
true 则禁用组件,false 则启用组件(默认为 false)。
|
Action | |
|
hidden
: Boolean
true 则隐藏组件,false 则显示组件(默认为 false)。
true 则隐藏组件,false 则显示组件(默认为 false)。
|
Action | |
|
handler
: Function
每个使用 action 对象的组件的主要事件触发时调用的处理函数(默认...
每个使用 action 对象的组件的主要事件触发时调用的处理函数(默认为 undefined)。
|
Action | |
|
scope
: Object
#handler 函数执行的作用域。
#handler 函数执行的作用域。
|
Action | |
| 属性 | 定义者 | |
|---|---|---|
|
*/: */
如果组件当前使用的 action 对象是隐藏的,则返回 true,...
如果组件当前使用的 action 对象是隐藏的,则返回 true,否则返回 false。只读。
|
Action | |