Clear Up
SharpKit Reference

AbstractComponent Class

NOTE This is a private utility class for internal use by the framework. Don't rely on its existence.

An abstract base class which provides shared methods for Components across the Sencha product line.

Please refer to sub class's documentation

Namespace: Ext

Base Types

Methods

Name Description
addChildEls(Object[]) Adds each argument passed to this method to the childEls array.
addChildEls() Adds each argument passed to this method to the childEls array.
addClass(object) Adds a CSS class to the top level element representing this component.

This method has been deprecated since 4.1

Use addCls instead.

addCls(object) Adds a CSS class to the top level element representing this component.
addClsWithUI(object, object) Adds a cls to the uiCls array, which will also call addUIClsToElement and adds to all elements of this component.
addEvents(object) Adds the specified events to the list of events which this Observable may fire.
addListener(object, Delegate, object, object) Appends an event handler to this object. For example:
myGridPanel.on("mouseover", this.onMouseOver, this);
            
The method also allows for a single argument to be passed which is a config object containing properties which specify multiple events. For example:
myGridPanel.on({
            cellClick: this.onCellClick,
            mouseover: this.onMouseOver,
            mouseout: this.onMouseOut,
            scope: this // Important. Ensure "this" is correct during handler execution
            });
            
One can also specify options for each event handler separately:
myGridPanel.on({
            cellClick: {fn: this.onCellClick, scope: this, single: true},
            mouseover: {fn: panel.onMouseOver, scope: panel}
            });
            
Names of methods in a specified scope may also be used. Note that scope MUST be specified to use this option:
myGridPanel.on({
            cellClick: {fn: 'onCellClick', scope: this, single: true},
            mouseover: {fn: 'onMouseOver', scope: panel}
            });
            
addManagedListener(object, object, Delegate, object, object) Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is destroyed.
addPropertyToState(object, JsString, object) Save a property to the given state object if it is not its default or configured value.
addStateEvents(object) Add events that will trigger the state to be saved. If the first argument is an array, each element of that array is the name of a state event. Otherwise, each argument passed to this method is the name of a state event.
addUIClsToElement(JsString) Method which adds a specified UI + uiCls to the components element. Can be overridden to remove the UI from more than just the components element.
afterComponentLayout(JsNumber, JsNumber, JsNumber, JsNumber) Called by the layout system after the Component has been layed out.

This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

afterRender() Allows addition of behavior after rendering is complete. At this stage the Component’s Element will have been styled according to the configuration, will have had any configured CSS class names added, and will be in the configured visibility and the configured enable state.

This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

afterSetPosition(JsNumber, JsNumber) Template method called after a Component has been positioned.

This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

animate(object) Performs custom animation on this object. This method is applicable to both the Component class and the Sprite class. It performs animated transitions of certain properties of this object over a specified timeline.
applyChildEls(object, object) Sets references to elements inside the component.
applyRenderSelectors() Sets references to elements inside the component. This applies renderSelectors as well as childEls.
applyState(object) Applies the state to the object. This should be overridden in subclasses to do more complex state operations. By default it applies the state properties onto the current object.
beforeComponentLayout(JsNumber, JsNumber) Occurs before componentLayout is run. Returning false from this method will prevent the componentLayout from being executed.

This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

beforeDestroy() Invoked before the Component is destroyed.

This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

cancelLayout(Component) Cancels layout of a component.
clearListeners() Removes all listeners for this object including the managed listeners
clearManagedListeners() Removes all managed listeners for this object.
continueFireEvent(JsString, object, object) Continue to fire event.
createRelayer(object, object) Creates an event handling function which refires the event from this object as the passed event name.
disable(object) Disable the component.
doApplyRenderTpl(object, object) Called from the selected frame generation template to insert this Component's inner structure inside the framing structure. When framing is used, a selected frame generation template is used as the primary template of the #getElConfig instead of the configured renderTpl. The renderTpl is invoked by this method which is injected into the framing template.
doAutoRender() Handles autoRender. Floating Components may have an ownerCt. If they are asking to be constrained, constrain them within that ownerCt, and have their z-index managed locally. Floating Components are always rendered to document.body
doComponentLayout() This method needs to be called whenever you change something on this component that requires the Component's layout to be recalculated.
enable(object) Enable the component
enableBubble(object) Enables events fired by this Observable to bubble up an owner hierarchy by calling this.getBubbleTarget() if present. There is no implementation in the Observable base class. This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly. Example:
  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');
            }
            }
            });
            
ensureAttachedToBody(object) Ensures that this component is attached to document.body. If the component was rendered to Ext.getDetachedBody, then it will be appended to document.body. Any configured position is also restored.
finishRender(JsNumber) This method visits the rendered component tree in a "top-down" order. That is, this code runs on a parent component before running on a child. This method calls the onRender method of each component.
fireEvent(JsString, Object[]) Fires the specified event with the passed parameters (minus the event name, plus the options object passed to addListener). An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble.
flushLayouts() Performs all pending layouts that were sceduled while suspendLayouts was in effect.
forceComponentLayout() Forces this component to redo its componentLayout.

This method has been deprecated since 4.1.0

Use updateLayout instead.

getActiveAnimation() Returns the current animation if this object has any effects actively running or queued, else returns false.
getBubbleParent() Gets the bubbling parent for an Observable
getBubbleTarget() Provides the link for Observable's fireEvent method to bubble up the ownership hierarchy.
getEl() Retrieves the top level element representing this component.
getFrameInfo() On render, reads an encoded style attribute, "background-position" from the style of this Component's element. This information is memoized based upon the CSS class name of this Component's element. Because child Components are rendered as textual HTML as part of the topmost Container, a dummy div is inserted into the document to receive the document element's CSS class name, and therefore style attributes.
getFrameTpl(object) Parameters
  • table : Object
  • getHeight() Gets the current height of the component's underlying element.
    getId() Retrieves the id of this component. Will autogenerate an id if one has not already been set.
    getInsertPosition(object) This function takes the position argument passed to onRender and returns a DOM element that you can use in the insertBefore.
    getItemId() Returns the value of itemId assigned to this component, or when that is not set, returns the value of id.
    getLoader() Gets the Ext.ComponentLoader for this Component.
    getPlugin(JsString) Retrieves a plugin by its pluginId which has been bound to this component.
    getSize() Gets the current size of the component's underlying element.
    getSizeModel(object) Returns an object that describes how this component's width and height are managed. All of these objects are shared and should not be modified.
    getState() The supplied default state gathering method for the AbstractComponent class. This method returns dimension settings such as flex, anchor, width and height along with collapsed state. Subclasses which implement more complex state should call the superclass's implementation, and apply their state to the result if this basic state is to be saved. Note that Component state will only be saved if the Component has a stateId and there as a StateProvider configured for the document.
    getStateId() Gets the state id for this object.
    getStyleProxy(object) Returns an offscreen div with the same class name as the element this is being rendered. This is because child item rendering takes place in a detached div which, being not part of the document, has no styling.
    getWidth() Gets the current width of the component's underlying element.
    getXTypes() Returns this Component's xtype hierarchy as a slash-delimited string. For a list of all available xtypes, see the Ext.Component header. If using your own subclasses, be aware that a Component must register its own xtype to participate in determination of inherited xtypes. Example usage:
    var t = new Ext.form.field.Text();
                alert(t.getXTypes());  // alerts 'component/field/textfield'
                
    hasActiveFx() Returns the current animation if this object has any effects actively running or queued, else returns false.

    This method has been deprecated since 4.0

    Replaced by getActiveAnimation

    hasCls(JsString) Checks if the specified CSS class exists on this element's DOM node.
    hasListener(JsString) Checks to see if this object has any listeners for a specified event, or whether the event bubbles. The answer indicates whether the event needs firing or not.
    hasUICls(JsString) Checks if there is currently a specified uiCls
    initFrame()
    initRenderData() Initialized the renderData to be used when rendering the renderTpl.
    initRenderTpl() Initializes the renderTpl.
    initState() Initializes the state of the object upon construction.
    is(JsString) Tests whether this Component matches the selector string.
    isDescendantOf(Container) Determines whether this component is the descendant of a particular container.
    isDisabled() Method to determine whether this Component is currently disabled.
    isDraggable() Method to determine whether this Component is draggable.
    isDroppable() Method to determine whether this Component is droppable.
    isFloating() Method to determine whether this Component is floating.
    isHidden() Method to determine whether this Component is currently set to hidden.
    isLayoutRoot() Determines whether this Component is the root of a layout. This returns true if this component can run its layout without assistance from or impact on its owner. If this component cannot run its layout given these restrictions, false is returned and its owner will be considered as the next candidate for the layout root. Setting the _isLayoutRoot property to true causes this method to always return true. This may be useful when updating a layout of a Container which shrink wraps content, and you know that it will not change size, and so can safely be the topmost participant in the layout run.
    isLayoutSuspended() Returns true if layout is suspended for this component. This can come from direct suspension of this component's layout activity (Ext.Container.suspendLayout) or if one of this component's containers is suspended.
    isVisible(object) Returns true if this component is visible.
    isXType(JsString, object) Tests whether or not this Component is of a specific xtype. This can test whether this Component is descended from the xtype (default) or whether it is directly of the xtype specified (shallow = true). If using your own subclasses, be aware that a Component must register its own xtype to participate in determination of inherited xtypes. For a list of all available xtypes, see the Ext.Component header. Example usage:
    var t = new Ext.form.field.Text();
                var isText = t.isXType('textfield');        // true
                var isBoxSubclass = t.isXType('field');       // true, descended from Ext.form.field.Base
                var isBoxInstance = t.isXType('field', true); // false, not a direct Ext.form.field.Base instance
                
    mon(object, object, Delegate, object, object) Shorthand for addManagedListener. Adds listeners to any Observable object (or Ext.Element) which are automatically removed when this Component is destroyed.
    mun(object, object, Delegate, object) Shorthand for removeManagedListener. Removes listeners that were added by the mon method.
    nextNode(object) Returns the next node in the Component tree in tree traversal order. Note that this is not limited to siblings, and if invoked upon a node with no matching siblings, will walk the tree to attempt to find a match. Contrast with nextSibling.
    nextSibling(object) Returns the next sibling of this Component. Optionally selects the next sibling which matches the passed ComponentQuery selector. May also be refered to as next() Note that this is limited to siblings, and if no siblings of the item match, null is returned. Contrast with nextNode
    on(object, Delegate, object, object) Shorthand for addListener. Appends an event handler to this object. For example:
    myGridPanel.on("mouseover", this.onMouseOver, this);
                
    The method also allows for a single argument to be passed which is a config object containing properties which specify multiple events. For example:
    myGridPanel.on({
                cellClick: this.onCellClick,
                mouseover: this.onMouseOver,
                mouseout: this.onMouseOut,
                scope: this // Important. Ensure "this" is correct during handler execution
                });
                
    One can also specify options for each event handler separately:
    myGridPanel.on({
                cellClick: {fn: this.onCellClick, scope: this, single: true},
                mouseover: {fn: panel.onMouseOver, scope: panel}
                });
                
    Names of methods in a specified scope may also be used. Note that scope MUST be specified to use this option:
    myGridPanel.on({
                cellClick: {fn: 'onCellClick', scope: this, single: true},
                mouseover: {fn: 'onMouseOver', scope: panel}
                });
                
    onAdded(Container, JsNumber) Method to manage awareness of when components are added to their respective Container, firing an added event. References are established at add time rather than at render time. Allows addition of behavior when a Component is added to a Container. At this stage, the Component is in the parent Container's collection of child items. After calling the superclass's onAdded, the ownerCt reference will be present, and if configured with a ref, the refOwner will be set.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onDisable() Allows addition of behavior to the disable operation. After calling the superclass’s onDisable, the Component will be disabled.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onEnable() Allows addition of behavior to the enable operation. After calling the superclass’s onEnable, the Component will be enabled.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onPosition(JsNumber, JsNumber) Called after the component is moved, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a move occurs.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onRemoved(bool) Method to manage awareness of when components are removed from their respective Container, firing a removed event. References are properly cleaned up after removing a component from its owning container. Allows addition of behavior when a Component is removed from its parent Container. At this stage, the Component has been removed from its parent Container's collection of child items, but has not been destroyed (It will be destroyed if the parent Container's autoDestroy is true, or if the remove call was passed a truthy second parameter). After calling the superclass's onRemoved, the ownerCt and the refOwner will not be present.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onRender(Element, JsNumber) Template method called when this Component's DOM structure is created. At this point, this Component's (and all descendants') DOM structure exists but it has not been layed out (positioned and sized). Subclasses which override this to gain access to the structure at render time should call the parent class's method before attempting to access any child elements of the Component.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onResize() Allows addition of behavior to the resize operation. Called when Ext.resizer.Resizer#drag event is fired.

    This is a template method. a hook into the functionality of this class. Feel free to override it in child classes.

    onStateChange() This method is called when any of the stateEvents are fired.
    prepareClass(Delegate) Prepares a given class for observable instances. This method is called when a class derives from this class or uses this class as a mixin.
    previousNode(object) Returns the previous node in the Component tree in tree traversal order. Note that this is not limited to siblings, and if invoked upon a node with no matching siblings, will walk the tree in reverse order to attempt to find a match. Contrast with previousSibling.
    previousSibling(object) Returns the previous sibling of this Component. Optionally selects the previous sibling which matches the passed ComponentQuery selector. May also be refered to as prev() Note that this is limited to siblings, and if no siblings of the item match, null is returned. Contrast with previousNode
    registerFloatingItem(object) Called by Component#doAutoRender Register a Container configured floating: true with this Component's ZIndexManager. Components added in ths way will not participate in any layout, but will be rendered upon first show in the way that Windows are.
    relayEvents(object, JsArray<T>, object) Relays selected events from the specified Observable as if the events were fired by this. For example if you are extending Grid, you might decide to forward some events from store. So you can do this inside your initComponent:
    this.relayEvents(this.getStore(), ['load']);
                
    The grid instance will then have an observable 'load' event which will be passed the parameters of the store's load event and any function fired with the grid's load event would have access to the grid using the this keyword.
    removeChildEls(Delegate) Removes items in the childEls array based on the return value of a supplied test function. The function is called with a entry in childEls and if the test function return true, that entry is removed. If false, that entry is kept.
    removeCls(object) Removes a CSS class from the top level element representing this component.
    removeClsWithUI(object) Removes a cls to the uiCls array, which will also call removeUIClsFromElement and removes it from all elements of this component.
    removeListener(JsString, Delegate, object) Removes an event handler.
    removeManagedListener(object, object, Delegate, object) Removes listeners that were added by the mon method.
    removeManagedListenerItem(bool, object) Remove a single managed listener item
    removeUIClsFromElement(JsString) Method which removes a specified UI + uiCls from the components element. The cls which is added to the element will be: this.baseCls + '-' + ui
    render(object, object) Renders the Component into the passed HTML element. If you are using a Container object to house this Component, then do not use the render method. A Container's child Components are rendered by that Container's layout manager when the Container is first rendered. If the Container is already rendered when a new child Component is added, you may need to call the Container's doLayout to refresh the view which causes any unrendered child Components to be rendered. This is required so that you can add multiple child components if needed while only refreshing the layout once. When creating complex UIs, it is important to remember that sizing and positioning of child items is the responsibility of the Container's layout manager. If you expect child items to be sized in response to user interactions, you must configure the Container with a layout manager which creates and manages the type of layout you have in mind. Omitting the Container's layout config means that a basic layout manager is used which does nothing but render child components sequentially into the Container. No sizing or positioning will be performed in this situation.
    resumeEvents() Resumes firing events (see suspendEvents). If events were suspended using the queueSuspended parameter, then all events fired during event suspension will be sent to any listeners now.
    resumeLayouts(object) Resumes layout activity in the whole framework. Ext.suspendLayouts is alias of suspendLayouts.
    savePropsToState(object, object) Gathers additional named properties of the instance and adds their current values to the passed state object.
    savePropToState(JsString, object, object) Conditionally saves a single property from this object to the given state object. The idea is to only save state which has changed from the initial state so that current software settings do not override future software settings. Only those values that are user-changed state should be saved.
    saveState() Saves the state of the object to the persistence store.
    sequenceFx() Ensures that all effects queued after sequenceFx is called on this object are run in sequence. This is the opposite of syncFx.
    setBorder(object) Parameters
  • border : String/Number

    The border, see border. If a falsey value is passed the border will be removed.

  • setDisabled(bool) Enable or disable the component.
    setDocked(object, object) Sets the dock position of this component in its parent panel. Note that this only has effect if this item is part of the dockedItems collection of a parent that has a DockLayout (note that any Panel has a DockLayout by default)
    setHeight(JsNumber) Sets the height of the component. This method fires the resize event.
    setPosition(JsNumber, JsNumber, object) Sets the left and top of the component. To set the page XY position instead, use setPagePosition. This method fires the move event.
    setSize(object, object) Sets the width and height of this Component. This method fires the resize event. This method can accept either width and height as separate arguments, or you can pass a size object like {width:10, height:20}.
    setUI(JsString) Sets the UI for the component. This will remove any existing UIs on the component. It will also loop through any uiCls set on the component and rename them so they include the new UI
    setupFramingTpl(object) Inject a reference to the function which applies the render template into the framing template. The framing template wraps the content.
    setVisible(bool) Convenience function to hide or show this component by boolean.
    setWidth(JsNumber) Sets the width of the component. This method fires the resize event.
    stopAnimation() Stops any running effects and clears this object's internal effects queue if it contains any additional effects that haven't started yet.
    stopFx() Stops any running effects and clears this object's internal effects queue if it contains any additional effects that haven't started yet.

    This method has been deprecated since 4.0

    Replaced by stopAnimation

    suspendEvents(bool) Suspends the firing of all events. (see resumeEvents)
    suspendLayouts() Stops layouts from happening in the whole framework. It's useful to suspend the layout activity while updating multiple components and containers:
      Ext.suspendLayouts();
                // batch of updates...
                Ext.resumeLayouts(true);
                
    Ext.suspendLayouts is alias of suspendLayouts. See also Ext.batchLayouts for more abstract way of doing this.
    syncFx() Ensures that all effects queued after syncFx is called on this object are run concurrently. This is the opposite of sequenceFx.
    un(JsString, Delegate, object) Shorthand for removeListener. Removes an event handler.
    up(object) Walks up the ownerCt axis looking for an ancestor Container which matches the passed simple selector. Example:
    var owningTabPanel = grid.up('tabpanel');
                
    update(object, object, object) Update the content area of a component.
    updateLayout(object) Updates this component's layout. If this update effects this components ownerCt, that component's updateLayout method will be called to perform the layout instead. Otherwise, just this component (and its child items) will layout.

    Fields

    Name Description
    autoEl A tag name or DomHelper spec used to create the Element which will encapsulate this Component. You do not normally need to specify this. For the base classes Ext.Component and Ext.container.Container, this defaults to 'div'. The more complex Sencha classes use a more complex DOM structure specified by their own renderTpls. This is intended to allow the developer to create application-specific utility Components encapsulated by different DOM elements. Example usage:
    {
                xtype: 'component',
                autoEl: {
                tag: 'img',
                src: 'http://www.example.com/example.jpg'
                }
                }, {
                xtype: 'component',
                autoEl: {
                tag: 'blockquote',
                html: 'autoEl is cool!'
                }
                }, {
                xtype: 'container',
                autoEl: 'ul',
                cls: 'ux-unordered-list',
                items: {
                xtype: 'component',
                autoEl: 'li',
                html: 'First list item'
                }
                }
                
    autoLoad An alias for loader config which also allows to specify just a string which will be used as the url that's automatically loaded:
      Ext.create('Ext.Component', {
                autoLoad: 'content.html',
                renderTo: Ext.getBody()
                });
                
    The above is the same as:
      Ext.create('Ext.Component', {
                loader: {
                url: 'content.html',
                autoLoad: true
                },
                renderTo: Ext.getBody()
                });
                
    Don't use it together with loader config.

    This cfg has been deprecated since 4.1.1

    Use loader config instead.

    autoRender This config is intended mainly for non-floating Components which may or may not be shown. Instead of using renderTo in the configuration, and rendering upon construction, this allows a Component to render itself upon first show. If floating is true, the value of this config is omited as if it is true. Specify as true to have this Component render to the document body upon first show. Specify as an element, or the ID of an element to have this Component render to a specific element upon first show. Defaults to: false
    autoShow True to automatically show the component upon creation. This config option may only be used for floating components or components that use autoRender. Defaults to false. Defaults to: false
    baseCls The base CSS class to apply to this components's element. This will also be prepended to elements within this component like Panel's body will get a class x-panel-body. This means that if you create a subclass of Panel, and you want it to get all the Panels styling for the element and the body, you leave the baseCls x-panel and use componentCls to add specific styling for this component. Defaults to: "x-component"
    border Specifies the border size for this component. The border can be a single numeric value to apply to all sides or it can be a CSS style specification for each style, for example: '10 5 3 10'. For components that have no border by default, setting this won't make the border appear by itself. You also need to specify border color and style:
    border: 5,
                style: {
                borderColor: 'red',
                borderStyle: 'solid'
                }
                
    To turn off the border, use border: false.
    childEls An array describing the child elements of the Component. Each member of the array is an object with these properties:
  • name - The property name on the Component for the child element.
  • itemId - The id to combine with the Component's id that is the id of the child element.
  • id - The id of the child element.
  • If the array member is a string, it is equivalent to { name: m, itemId: m }. For example, a Component which renders a title and body text:
      Ext.create('Ext.Component', {
                renderTo: Ext.getBody(),
                renderTpl: [
                '<h1 id="{id}-title">{title}</h1>',
                '<p>{msg}</p>',
                ],
                renderData: {
                title: "Error",
                msg: "Something went wrong"
                },
                childEls: ["title"],
                listeners: {
                afterrender: function(cmp){
                // After rendering the component will have a title property
                cmp.title.setStyle({color: "red"});
                }
                }
                });
                
    A more flexible, but somewhat slower, approach is renderSelectors.
    cls An optional extra CSS class that will be added to this component's Element. This can be useful for adding customized styles to the component or any of its children using standard CSS rules. Defaults to: ""
    componentCls CSS Class to be added to a components root level element to give distinction to it via styling.
    componentLayout The sizing and positioning of a Component's internal Elements is the responsibility of the Component's layout manager which sizes a Component's internal structure in response to the Component being sized. Generally, developers will not use this configuration as all provided Components which need their internal elements sizing (Such as input fields) come with their own componentLayout managers. The default layout manager will be used on instances of the base Ext.Component class which simply sizes the Component's encapsulating element to the height and width specified in the setSize method.
    contentEl Specify an existing HTML element, or the id of an existing HTML element to use as the content for this component. This config option is used to take an existing HTML element and place it in the layout element of a new component (it simply moves the specified DOM element after the Component is rendered to use as the content. Notes: The specified HTML element is appended to the layout element of the component after any configured HTML has been inserted, and so the document will not contain this element at the time the render event is fired. The specified HTML element used will not participate in any layout scheme that the Component may use. It is just HTML. Layouts operate on child items . Add either the x-hidden or the x-hide-display CSS class to prevent a brief flicker of the content before it is rendered to the panel.
    data The initial set of data to apply to the tpl to update the content area of the Component.
    disabled True to disable the component. Defaults to: false
    disabledCls CSS class to add when the Component is disabled. Defaults to 'x-item-disabled'. Defaults to: "x-item-disabled"
    floating Create the Component as a floating and use absolute positioning. The z-index of floating Components is handled by a ZIndexManager. If you simply render a floating Component into the DOM, it will be managed by the global WindowManager. If you include a floating Component as a child item of a Container, then upon render, ExtJS will seek an ancestor floating Component to house a new ZIndexManager instance to manage its descendant floaters. If no floating ancestor can be found, the global WindowManager will be used. When a floating Component which has a ZindexManager managing descendant floaters is destroyed, those descendant floaters will also be destroyed. Defaults to: false
    frame Specify as true to have the Component inject framing elements within the Component at render time to provide a graphical rounded frame around the Component content. This is only necessary when running on outdated, or non standard-compliant browsers such as Microsoft's Internet Explorer prior to version 9 which do not support rounded corners natively. The extra space taken up by this framing is available from the read only property frameSize.
    height The height of this component in pixels.
    hidden True to hide the component. Defaults to: false
    hideMode A String which specifies how this Component's encapsulating DOM element will be hidden. Values may be:
  • 'display' : The Component will be hidden using the display: none style.
  • 'visibility' : The Component will be hidden using the visibility: hidden style.
  • 'offsets' : The Component will be hidden by absolutely positioning it out of the visible area of the document. This is useful when a hidden Component must maintain measurable dimensions. Hiding using display results in a Component having zero dimensions.
  • Defaults to: "display"
    html An HTML fragment, or a DomHelper specification to use as the layout element content. The HTML content is added after the component is rendered, so the document will not contain this HTML at the time the render event is fired. This content is inserted into the body before any configured contentEl is appended. Defaults to: ""
    id The unique id of this component instance. It should not be necessary to use this configuration except for singleton objects in your application. Components created with an id may be accessed globally using Ext.getCmp. Instead of using assigned ids, use the itemId config, and ComponentQuery which provides selector-based searching for Sencha Components analogous to DOM querying. The Container class contains shortcut methods to query its descendant Components by selector. Note that this id will also be used as the element id for the containing HTML element that is rendered to the page for this component. This allows you to write id-based CSS rules to style the specific instance of this component uniquely, and also to select sub-elements using this component's id as the parent. Note: to avoid complications imposed by a unique id also see itemId . Note: to access the container of a Component see ownerCt . Defaults to an auto-assigned id.
    itemId An itemId can be used as an alternative way to get a reference to a component when no object reference is available. Instead of using an id with Ext.getCmp, use itemId with Ext.container.Container.getComponent which will retrieve itemId's or id's. Since itemId's are an index to the container's internal MixedCollection, the itemId is scoped locally to the container -- avoiding potential conflicts with Ext.ComponentManager which requires a unique id.
    var c = new Ext.panel.Panel({ //
                height: 300,
                renderTo: document.body,
                layout: 'auto',
                items: [
                {
                itemId: 'p1',
                title: 'Panel 1',
                height: 150
                },
                {
                itemId: 'p2',
                title: 'Panel 2',
                height: 150
                }
                ]
                })
                p1 = c.getComponent('p1'); // not the same as Ext.getCmp()
                p2 = p1.ownerCt.getComponent('p2'); // reference via a sibling
                
    Also see id, Ext.container.Container.query , Ext.container.Container.down and Ext.container.Container.child . Note: to access the container of an item see ownerCt.
    listeners A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. DOM events from Ext JS Components While some Ext JS Component classes export selected DOM events (e.g. "click", "mouseover" etc), this is usually only done when extra value can be added. For example the DataView's itemclick event passing the node clicked on. To access DOM events directly from a child element of a Component, we need to specify the element option to identify the Component property to add a DOM listener to:
    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'); }
                }
                }
                });
                
    loader A configuration object or an instance of a Ext.ComponentLoader to load remote content for this Component.
      Ext.create('Ext.Component', {
                loader: {
                url: 'content.html',
                autoLoad: true
                },
                renderTo: Ext.getBody()
                });
                
    margin Specifies the margin for this component. The margin can be a single numeric value to apply to all sides or it can be a CSS style specification for each style, for example: '10 5 3 10'.
    maxHeight The maximum value in pixels which this Component will set its height to. Warning: This will override any size management applied by layout managers.
    maxWidth The maximum value in pixels which this Component will set its width to. Warning: This will override any size management applied by layout managers.
    minHeight The minimum value in pixels which this Component will set its height to. Warning: This will override any size management applied by layout managers.
    minWidth The minimum value in pixels which this Component will set its width to. Warning: This will override any size management applied by layout managers.
    overCls An optional extra CSS class that will be added to this component's Element when the mouse moves over the Element, and removed when the mouse moves out. This can be useful for adding customized 'active' or 'hover' styles to the component or any of its children using standard CSS rules. Defaults to: ""
    padding Specifies the padding for this component. The padding can be a single numeric value to apply to all sides or it can be a CSS style specification for each style, for example: '10 5 3 10'.
    plugins An object or array of objects that will provide custom functionality for this component. The only requirement for a valid plugin is that it contain an init method that accepts a reference of type Ext.Component. When a component is created, if any plugins are available, the component will call the init method on each plugin, passing a reference to itself. Each plugin can then call methods or respond to events on the component as needed to provide its functionality.
    renderData The data used by renderTpl in addition to the following property values of the component:
  • id
  • ui
  • uiCls
  • baseCls
  • componentCls
  • frame
  • See renderSelectors and childEls for usage examples.
    renderSelectors An object containing properties specifying DomQuery selectors which identify child elements created by the render process. After the Component's internal structure is rendered according to the renderTpl, this object is iterated through, and the found Elements are added as properties to the Component using the renderSelector property name. For example, a Component which renderes a title and description into its element:
      Ext.create('Ext.Component', {
                renderTo: Ext.getBody(),
                renderTpl: [
                '<h1 class="title">{title}</h1>',
                '<p>{desc}</p>'
                ],
                renderData: {
                title: "Error",
                desc: "Something went wrong"
                },
                renderSelectors: {
                titleEl: 'h1.title',
                descEl: 'p'
                },
                listeners: {
                afterrender: function(cmp){
                // After rendering the component will have a titleEl and descEl properties
                cmp.titleEl.setStyle({color: "red"});
                }
                }
                });
                
    For a faster, but less flexible, alternative that achieves the same end result (properties for child elements on the Component after render), see childEls and addChildEls.
    renderTo Specify the id of the element, a DOM element or an existing Element that this component will be rendered into. Notes: Do not use this option if the Component is to be a child item of a Container. It is the responsibility of the Container's layout manager to render and manage its child items. When using this config, a call to render() is not required. See also: render.
    renderTpl An XTemplate used to create the internal structure inside this Component's encapsulating Element. You do not normally need to specify this. For the base classes Ext.Component and Ext.container.Container, this defaults to null which means that they will be initially rendered with no internal structure; they render their Element empty. The more specialized ExtJS and Touch classes which use a more complex DOM structure, provide their own template definitions. This is intended to allow the developer to create application-specific utility Components with customized internal structure. Upon rendering, any created child elements may be automatically imported into object properties using the renderSelectors and childEls options. Defaults to: "{%this.renderContent(out,values)%}"
    saveDelay A buffer to be applied if many state events are fired within a short period. Defaults to: 100
    shrinkWrap If this property is a number, it is interpreted as follows:
  • 0: Neither width nor height depend on content. This is equivalent to false.
  • 1: Width depends on content (shrink wraps), but height does not.
  • 2: Height depends on content (shrink wraps), but width does not. The default.
  • 3: Both width and height depend on content (shrink wrap). This is equivalent to true.
  • In CSS terms, shrink-wrap width is analogous to an inline-block element as opposed to a block-level element. Some container layouts always shrink-wrap their children, effectively ignoring this property (e.g., Ext.layout.container.HBox, Ext.layout.container.VBox, Ext.layout.component.Dock). Defaults to: 2
    stateEvents An array of events that, when fired, should trigger this object to save its state. Defaults to none. stateEvents may be any type of event supported by this object, including browser or custom events (e.g., ['click', 'customerchange']). See stateful for an explanation of saving and restoring object state.
    stateful A flag which causes the object to attempt to restore the state of internal properties from a saved state on startup. The object must have a stateId for state to be managed. Auto-generated ids are not guaranteed to be stable across page loads and cannot be relied upon to save and restore the same state for a object. For state saving to work, the state manager's provider must have been set to an implementation of Ext.state.Provider which overrides the set and get methods to save and recall name/value pairs. A built-in implementation, Ext.state.CookieProvider is available. To set the state provider for the current page: Ext.state.Manager.setProvider(new Ext.state.CookieProvider({
    expires: new Date(new Date().getTime()+(1000*60*60*24*7)), //7 days from now
                
    })); A stateful object attempts to save state when one of the events listed in the stateEvents configuration fires. To save state, a stateful object first serializes its state by calling getState . The Component base class implements getState to save its width and height within the state only if they were initially configured, and have changed from the configured value. The Panel class saves its collapsed state in addition to that. The Grid class saves its column state in addition to its superclass state. If there is more application state to be save, the developer must provide an implementation which first calls the superclass method to inherit the above behaviour, and then injects new properties into the returned object. The value yielded by getState is passed to Ext.state.Manager.set which uses the configured Ext.state.Provider to save the object keyed by the stateId. During construction, a stateful object attempts to restore its state by calling Ext.state.Manager.get passing the stateId The resulting object is passed to applyState*. The default implementation of applyState simply copies properties into the object, but a developer may override this to support restoration of more complex application state. You can perform extra processing on state save and restore by attaching handlers to the beforestaterestore, staterestore, beforestatesave and statesave events. Defaults to: false
    stateId The unique id for this object to use for state management purposes. See stateful for an explanation of saving and restoring state.
    style A custom style specification to be applied to this component's Element. Should be a valid argument to Ext.Element.applyStyles.
    new Ext.panel.Panel({
                title: 'Some Title',
                renderTo: Ext.getBody(),
                width: 400, height: 300,
                layout: 'form',
                items: [{
                xtype: 'textarea',
                style: {
                width: '95%',
                marginBottom: '10px'
                }
                },
                new Ext.button.Button({
                text: 'Send',
                minWidth: '100',
                style: {
                marginBottom: '10px'
                }
                })
                ]
                });
                
    styleHtmlCls The class that is added to the content target when you set styleHtmlContent to true. Defaults to: "x-html"
    styleHtmlContent True to automatically style the html inside the content target of this component (body for panels). Defaults to: false
    tpl An Ext.Template, Ext.XTemplate or an array of strings to form an Ext.XTemplate. Used in conjunction with the data and tplWriteMode configurations.
    tplWriteMode The Ext.(X)Template method to use when updating the content area of the Component. See Ext.XTemplate.overwrite for information on default mode. Defaults to: "overwrite"
    ui A UI style for a component. Defaults to: "default"
    uiCls An array of of classNames which are currently applied to this component Defaults to: []
    width The width of this component in pixels.
    xtype This property provides a shorter alternative to creating objects than using a full class name. Using xtype is the most common way to define component instances, especially in a container. For example, the items in a form containing text fields could be created explicitly like so:
    items: [
               Ext.create('Ext.form.field.Text', {
               fieldLabel: 'Foo'
               }),
               Ext.create('Ext.form.field.Text', {
               fieldLabel: 'Bar'
               }),
               Ext.create('Ext.form.field.Number', {
               fieldLabel: 'Num'
               })
               ]
                
    But by using xtype, the above becomes:
    items: [
               {
               xtype: 'textfield',
               fieldLabel: 'Foo'
               },
               {
               xtype: 'textfield',
               fieldLabel: 'Bar'
               },
               {
               xtype: 'numberfield',
               fieldLabel: 'Num'
               }
               ]
                
    When the xtype is common to many items, Ext.container.AbstractContainer.defaultType is another way to specify the xtype for all items that don't have an explicit xtype:
    defaultType: 'textfield',
               items: [
               { fieldLabel: 'Foo' },
               { fieldLabel: 'Bar' },
               { fieldLabel: 'Num', xtype: 'numberfield' }
               ]
                
    Each member of the items array is now just a "configuration object". These objects are used to create and configure component instances. A configuration object can be manually used to instantiate a component using Ext.widget:
    var text1 = Ext.create('Ext.form.field.Text', {
               fieldLabel: 'Foo'
               });
               // or alternatively:
               var text1 = Ext.widget({
               xtype: 'textfield',
               fieldLabel: 'Foo'
               });
                
    This conversion of configuration objects into instantiated components is done when a container is created as part of its {Ext.container.AbstractContainer.initComponent} process. As part of the same process, the items array is converted from its raw array form into a Ext.util.MixedCollection instance. You can define your own xtype on a custom component by specifying the xtype property in Ext.define. For example:
      Ext.define('MyApp.PressMeButton', {
                extend: 'Ext.button.Button',
                xtype: 'pressmebutton',
                text: 'Press Me'
                });
                
    Care should be taken when naming an xtype in a custom component because there is a single, shared scope for all xtypes. Third part components should consider using a prefix to avoid collisions.
      Ext.define('Foo.form.CoolButton', {
                extend: 'Ext.button.Button',
                xtype: 'ux-coolbutton',
                text: 'Cool!'
                });
                

    Properties

    Name Description
    draggable Indicates whether or not the component can be dragged. Defaults to: false
    eventsSuspended Initial suspended call count. Incremented when suspendEvents is called, decremented when resumeEvents is called. Defaults to: 0
    frameSize Indicates the width of any framing elements which were added within the encapsulating element to provide graphical, rounded borders. See the frame config. This is an object containing the frame width in pixels for all four sides of the Component containing the following properties: Defaults to: {left: 0, top: 0, right: 0, bottom: 0, width: 0, height: 0}
  • top : Number (optional)

    The width of the top framing element in pixels.

    Defaults to: 0

  • right : Number (optional)

    The width of the right framing element in pixels.

    Defaults to: 0

  • bottom : Number (optional)

    The width of the bottom framing element in pixels.

    Defaults to: 0

  • left : Number (optional)

    The width of the left framing element in pixels.

    Defaults to: 0

  • width : Number (optional)

    The total width of the left and right framing elements in pixels.

    Defaults to: 0

  • height : Number (optional)

    The total height of the top and right bottom elements in pixels.

    Defaults to: 0

  • hasListeners This object holds a key for any event that has a listener. The listener may be set directly on the instance, or on its class or a super class (via observe) or on the MVC EventBus. The values of this object are truthy (a non-zero number) and falsy (0 or undefined). They do not represent an exact count of listeners. The value for an event is truthy if the event must be fired and is falsy if there is no need to fire the event. The intended use of this property is to avoid the expense of fireEvent calls when there are no listeners. This can be particularly helpful when one would otherwise have to call fireEvent hundreds or thousands of times. It is used like this:
    if (this.hasListeners.foo) {
               this.fireEvent('foo', this, arg1);
               }
                
    isComponent true in this class to identify an object as an instantiated Component, or subclass thereof. Defaults to: true
    isObservable true in this class to identify an object as an instantiated Observable, or subclass thereof. Defaults to: true
    maskOnDisable This is an internal flag that you use when creating custom components. By default this is set to true which means that every component gets a mask when it's disabled. Components like FieldContainer, FieldSet, Field, Button, Tab override this property to false since they want to implement custom disable logic. Defaults to: true
    ownerCt This Component's owner Container (is set automatically when this Component is added to a Container). Note: to access items within the Container see itemId.
    rendered Indicates whether or not the component has been rendered. Defaults to: false
    © Copyright 2005-2011 SharpKit. All rights reserved.