// display a dropdown menu:
new Ext.button.Split({
renderTo: 'button-ct', // the container id
text: 'Options',
handler: optionsHandler, // handle a click on the button itself
menu: new Ext.menu.Menu({
items: [
// these items will render as dropdown menu items when the arrow is clicked:
{text: 'Item 1', handler: item1Handler},
{text: 'Item 2', handler: item2Handler}
]
})
});
// Instead of showing a menu, you provide any type of custom
// functionality you want when the dropdown arrow is clicked:
new Ext.button.Split({
renderTo: 'button-ct',
text: 'Options',
handler: optionsHandler,
arrowHandler: myCustomHandler
});
(Optional) The side of the Button box to render the arrow if the button has an associated menu. Two values are allowed:
Defaults to 'right'.
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'
}
}
This config is intended mainly for 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.
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.
This defaults to true
for the Window class.
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.
Optional. Specify an existing HTML element, or the id
of an existing HTML element to use as the content
for this component.
layout
scheme that the Component may use. It is just HTML. Layouts operate on child items
.x-hidden
or the x-hide-display
CSS class to
prevent a brief flicker of the content before it is rendered to the panel.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.
b
: Buttone
: EventObject'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.'display'
.(Optional) The side of the Button box to render the icon. Four values are allowed:
Defaults to 'left'.
The unique id of this component instance (defaults to an auto-assigned id).
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
.
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.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.ComponentMgr which requires a unique
id
.
var c = new Ext.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
Note: to access the container of an item see ownerCt.
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 ExtJs Components
While some ExtJs 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
click
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({
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'); }
}
}
});
The maximum value in pixels which this Component will set its height to.
Warning: This will override any size management applied by layout managers.
The maximum value in pixels which this Component will set its width to.
Warning: This will override any size management applied by layout managers.
The minimum value in pixels which this Component will set its height to.
Warning: This will override any size management applied by layout managers.
overflowText
.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 rendered an image, and description into its element might use the following properties coded into its prototype:
renderTpl: '"{imageUrl}" class="x-image-component-img">"x-image-component-desc">{description}',
renderSelectors: {
image: 'img.x-image-component-img',
descEl: 'div.x-image-component-desc'
}
After rendering, the Component would have a property image
referencing its child img
Element,
and a property descEl
referencing the div
Element which contains the description.
Specify the id of the element, a DOM element or an existing Element that this component will be rendered into.
See render
also.
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 option.
Specify as true
to apply a Resizer to this Component
after rendering.
May also be specified as a config object to be passed to the constructor of Resizer
to override any defaults. By default the Component passes its minimum and maximum size, and uses
Ext.resize.Resizer.dynamic: false
(Optional) The size of the Button. Three values are allowed:
Defaults to 'small'.
handler
and toggleHandler
is
executed. Defaults to this Button.handler
and toggleHandler
is
executed. Defaults to this Button.new Ext.Panel({
title: 'Some Title',
renderTo: Ext.getBody(),
width: 400, height: 300,
layout: 'form',
items: [{
xtype: 'textarea',
style: {
width: '95%',
marginBottom: '10px'
}
},
new Ext.Button({
text: 'Send',
minWidth: '100',
style: {
marginBottom: '10px'
}
})
]
});
A Template used to create the Button's DOM structure.
Instances, or subclasses which need a different DOM structure may provide a different template layout in conjunction with an implementation of getTemplateArgs.data
and
tplWriteMode
configurations.'overwrite'
(see Ext.XTemplate.overwrite
).(Optional) The UI specified for the button.
Defaults to 'default'.
(Optional) The UI specified for the button.
Defaults to 'default'.
(Optional) The className used for the inner arrow element if the button has a menu.
(Optional) The className used for the inner arrow element if the button has a menu.
Read-only property indicating 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:
top
The width of the top framing element in pixels.right
The width of the right framing element in pixels.bottom
The width of the bottom framing element in pixels.left
The width of the left framing element in pixels.Optional. Only valid for floating Components. A reference to the ZIndexManager that should manage this Component.
This defaults to the global Ext.WindowMgr for floating Components that are programatically rendered.
For floating Components which are added at a Container, the Container assigns a ZIndexManager.
true
or the first event name string if multiple event names are being passed as separate parameters.this.addEvents('storeloaded', 'storecleared');
this
reference) in which the handler function is executed.
If omitted, defaults to the object which fired the event.this
reference) in which the handler function is executed.
If omitted, defaults to the object which fired the event.This option is useful during Component construction to add DOM event listeners to elements of Components which will exist only after the Component is rendered. For example, to add a click listener to a Panel's body:
new Ext.Panel({
title: 'The title',
listeners: {
click: this.handlePanelClick,
element: 'body'
}
});
When added in this way, the options available are the options applicable to Ext.core.Element.addListener
Combining Options
Using the options argument, it is possible to combine different types of listeners:
A delayed, one-time listener.
myPanel.on('hide', this.handleClick, this, {
single: true,
delay: 100
});
Attaching multiple handlers in 1 call
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
});
.
Adds listeners to any Observable object (or Element) which are automatically removed when this Component is destroyed.
ename
parameter was an event name, this
is the handler function.ename
parameter was an event name, this
is the scope (this
reference) in which the handler function is executed.ename
parameter was an event name, this
is the addListener options.this
reference) in which the function is executed. Defaults to the Observable firing the event.this
reference) in which the handler function is executed.
If omitted, defaults to the object which fired the event.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, {
// Add functionality to Field's initComponent to enable the change event to bubble
initComponent : Ext.Function.createSequence(Ext.form.Field.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');
}
}
});
Find a container above this component at any level by xtype or class
See also the up method.
Fires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble.
This method returns an object which provides substitution parameters for the XTemplate used to create this Button's DOM structure.
Instances or subclasses which use a different Template to create a different DOM structure may need to provide their own implementation of this method.
The default implementation which provides data for the default template returns an Object containing the following properties:
type
: The <button>'s typesplitCls
: A CSS class to determine the presence and position of an arrow icon. ('x-btn-arrow'
or 'x-btn-arrow-bottom'
or ''
)cls
: A CSS class name applied to the Button's main <tbody> element which determines the button's scale and icon alignment.text
: The text to display ion the Button.tabIndex
: The tab index within the input flow.var t = new Ext.form.Text();
alert(t.getXType()); // alerts 'textfield'
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.Text();
alert(t.getXTypes()); // alerts 'component/field/textfield'
Optional. Pass true
to interrogate the visibility status of all
parent Containers to determine whether this Component is truly visible to the user.
Generally, to determine whether a Component is hidden, the no argument form is needed. For example when creating dynamically laid out UIs in a hidden Container before showing them.
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.Text();
var isText = t.isXType('textfield'); // true
var isBoxSubclass = t.isXType('field'); // true, descended from Ext.form.Field
var isBoxInstance = t.isXType('field', true); // false, not a direct Ext.form.Field instance
Returns the next sibling of this Component.
Optionally selects the next sibling which matches the passed ComponentQuery selector.
May also be refered to as prev()
This makes any event fired on any instance of the passed class also fire a single event through the class allowing for central handling of events on many instances at once.
Usage:
Ext.util.Observable.observe(Ext.data.Connection);
Ext.data.Connection.on('beforerequest', function(con, options) {
console.log('Ajax request made to ' + options.url);
});
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()
this
.ename
parameter was an event name, this
is the handler function.ename
parameter was an event name, this
is the scope (this
reference) in which the handler function is executed.queueSuspended
parameter, then all
events fired during event suspension will be sent to any listeners now.this
reference) in which the handler function is executed.
Defaults to this Button.{width:10, height:20}
.{width: widthValue, height: heightValue}
.undefined
to leave the width unchanged.undefined
to leave the height unchanged.Shows this Component, rendering it first if Ext.AbstractComponent.autoRender is true
.
For a Window, it activates it and brings it to front if hidden.
this
reference) in which the callback is executed. Defaults to this Component.Walks up the ownerCt
axis looking for an ancestor Container which matches
the passed simple selector.
Example:
var owningTabContainer = grid.up('tabcontainer');
undefined
if no match was found).