X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/2e847cf21b8ab9d15fa167b315ca5b2fa92638fc..7a654f8d43fdb43d78b63d90528bed6e86b608cc:/docs/api/Ext.Action.html diff --git a/docs/api/Ext.Action.html b/docs/api/Ext.Action.html new file mode 100644 index 00000000..6418d6fd --- /dev/null +++ b/docs/api/Ext.Action.html @@ -0,0 +1,233 @@ +Ext.Action | Ext JS 4.0 Documentation +
For up to date documentation and features, visit +http://docs.sencha.com/ext-js/4-0

Sencha Documentation

+ + + + + +

An Action is a piece of reusable functionality that can be abstracted out of any particular component so that it +can be usefully shared among multiple components. Actions let you share handlers, configuration options and UI +updates across any components that support the Action interface (primarily Ext.toolbar.Toolbar, Ext.button.Button +and Ext.menu.Menu components).

+ + +

Use a single Action instance as the config object for any number of UI Components which share the same configuration. The +Action not only supplies the configuration, but allows all Components based upon it to have a common set of methods +called at once through a single call to the Action.

+ + +

Any Component that is to be configured with an Action must also support +the following methods:

    +
  • setText(string)
  • +
  • setIconCls(string)
  • +
  • setDisabled(boolean)
  • +
  • setVisible(boolean)
  • +
  • setHandler(function)
.

+ + +

This allows the Action to control its associated Components.

+ + +

Example usage:

+ +
// 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',
+    itemId: 'myAction'
+});
+
+var panel = new Ext.panel.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.Button(action)
+    ],
+    renderTo: Ext.getBody()
+});
+
+// Change the text for all components using the Action
+action.setText('Something else');
+
+// Reference an Action through a container using the itemId
+var btn = panel.getComponent('myAction');
+var aRef = btn.baseAction;
+aRef.setText('New text');
+
+ +
Defined By

Config Options

CSS Class configs

 
The CSS class selector that specifies a background image to be used as the header icon for +all components configured ...

The CSS class selector that specifies a background image to be used as the header icon for +all components configured by this Action (defaults to '').

+ +

An example of specifying a custom icon class would be something like: +

+ + +
// specify the property in the config for the class:
+     ...
+     iconCls: 'do-something'
+
+// css class that specifies background image to be used as the icon image:
+.do-something { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }
+
+ +

Other Configs

 

True to disable all components configured by this Action, false to enable them (defaults to false).

+

True to disable all components configured by this Action, false to enable them (defaults to false).

+
 
The function that will be invoked by each component tied to this Action +when the component's primary event is trigger...

The function that will be invoked by each component tied to this Action +when the component's primary event is triggered (defaults to undefined).

+
 

True to hide all components configured by this Action, false to show them (defaults to false).

+

True to hide all components configured by this Action, false to show them (defaults to false).

+
 
The CSS class selector that specifies a background image to be used as the header icon for +all components configured ...

The CSS class selector that specifies a background image to be used as the header icon for +all components configured by this Action (defaults to '').

+ +

An example of specifying a custom icon class would be something like: +

+ + +
// specify the property in the config for the class:
+     ...
+     iconCls: 'do-something'
+
+// css class that specifies background image to be used as the icon image:
+.do-something { background-image: url(../images/my-icon.gif) 0 6px no-repeat !important; }
+
+ +
 

The scope (this reference) in which the +handler is executed. Defaults to the browser window.

+

The scope (this reference) in which the +handler is executed. Defaults to the browser window.

+
 

The text to set for all components configured by this Action (defaults to '').

+

The text to set for all components configured by this Action (defaults to '').

+
Defined By

Methods

 
Action( +Object config) + : void

 

+

Parameters

  • config : Object

    The configuration options

    +

Returns

  • void    +
 

Disables all components configured by this Action.

+

Disables all components configured by this Action.

+

Returns

  • void    +
 
each( +Function fn, Object scope) + : void
Executes the specified function once for each Component currently tied to this Action. The function passed +in should...

Executes the specified function once for each Component currently tied to this Action. The function passed +in should accept a single argument that will be an object that supports the basic Action config/method interface.

+

Parameters

  • fn : Function

    The function to execute for each component

    +
  • scope : Object

    The scope (this reference) in which the function is executed. Defaults to the Component.

    +

Returns

  • void    +
 

Enables all components configured by this Action.

+

Enables all components configured by this Action.

+

Returns

  • void    +
 
execute( +[Mixed arg1], [Mixed arg2], [Mixed etc]) + : void
Executes this Action manually using the handler function specified in the original config object +or the handler funct...

Executes this Action manually using the handler function specified in the original config object +or the handler function set with setHandler. Any arguments passed to this +function will be passed on to the handler function.

+

Parameters

  • arg1 : Mixed

    (optional) Variable number of arguments passed to the handler function

    +
  • arg2 : Mixed

    (optional)

    +
  • etc : Mixed

    ... (optional)

    +

Returns

  • void    +
 

Gets the icon CSS class currently used by all components configured by this Action.

+

Gets the icon CSS class currently used by all components configured by this Action.

+

Returns

  • void    +
 

Gets the text currently displayed by all components configured by this Action.

+

Gets the text currently displayed by all components configured by this Action.

+

Returns

  • void    +
 

Hides all components configured by this Action.

+

Hides all components configured by this Action.

+

Returns

  • void    +
 

Returns true if the components using this Action are currently disabled, else returns false.

+

Returns true if the components using this Action are currently disabled, else returns false.

+

Returns

  • void    +
 

Returns true if the components configured by this Action are currently hidden, else returns false.

+

Returns true if the components configured by this Action are currently hidden, else returns false.

+

Returns

  • void    +
 
setDisabled( +Boolean disabled) + : void

Sets the disabled state of all components configured by this Action. Shortcut method +for enable and disable.

+

Sets the disabled state of all components configured by this Action. Shortcut method +for enable and disable.

+

Parameters

  • disabled : Boolean

    True to disable the component, false to enable it

    +

Returns

  • void    +
 
setHandler( +Function fn, Object scope) + : void

Sets the function that will be called by each Component using this action when its primary event is triggered.

+

Sets the function that will be called by each Component using this action when its primary event is triggered.

+

Parameters

  • fn : Function

    The function that will be invoked by the action's components. The function +will be called with no arguments.

    +
  • scope : Object

    The scope (this reference) in which the function is executed. Defaults to the Component firing the event.

    +

Returns

  • void    +
 
setHidden( +Boolean hidden) + : void

Sets the hidden state of all components configured by this Action. Shortcut method +for hide and show.

+

Sets the hidden state of all components configured by this Action. Shortcut method +for hide and show.

+

Parameters

  • hidden : Boolean

    True to hide the component, false to show it

    +

Returns

  • void    +
 
setIconCls( +String cls) + : void
Sets the icon CSS class for all components configured by this Action. The class should supply +a background image tha...

Sets the icon CSS class for all components configured by this Action. The class should supply +a background image that will be used as the icon image.

+

Parameters

  • cls : String

    The CSS class supplying the icon image

    +

Returns

  • void    +
 
setText( +String text) + : void

Sets the text to be displayed by all components configured by this Action.

+

Sets the text to be displayed by all components configured by this Action.

+

Parameters

  • text : String

    The text to display

    +

Returns

  • void    +
 

Shows all components configured by this Action.

+

Shows all components configured by this Action.

+

Returns

  • void    +
\ No newline at end of file