Clear Up
SharpKit Reference

AbstractComponentConfig Class

Namespace: Ext

Base Types

System.Object

Derived Types

Constructors

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"
    draggable Allows the component to be dragged. Defaults to: false
    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!'
                });
                
    © Copyright 2005-2011 SharpKit. All rights reserved.