A field with a pair of up/down spinner buttons. This class is not normally instantiated directly, instead it is subclassed and the onSpinUp and onSpinDown methods are implemented to handle when the buttons are clicked. A good example of this is the Ext.form.Number field which uses the spinner to increment and decrement the field's value by its step config value.
By default, pressing the up and down arrow keys will also trigger the onSpinUp and onSpinDown methods; to prevent this, set keyNavEnabled = false.
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.
A list of event names that will be listened for on the field's input element, which will cause the field's value to be checked for changes. If a change is detected, the change event will be fired, followed by validation if the validateOnChange option is enabled.
Defaults to ['change', 'propertychange'] in Internet Explorer, and ['change', 'input', 'textInput', 'keyup', 'dragdrop'] in other browsers. This catches all the ways that field values can be changed in most supported browsers; the only known exceptions at the time of writing are:
If you need to guarantee on-the-fly change notifications including these edge cases, you can call the checkChange method on a repeating interval, e.g. using Ext.TaskMgr, or if the field is within a Ext.form.FormPanel, you can use the FormPanel's Ext.form.FormPanel.pollForChanges configuration to set up such a task automatically.
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.The default text to place into an empty field (defaults to undefined).
Note that normally this value will be submitted to the server if this field is enabled; to prevent this you can set the submitEmptyText option of Ext.form.Basic.submit to false.
Also note that if you use inputType:'file', emptyText is not supported and should be avoided.
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.
'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'
.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
.
The type attribute for input fields -- e.g. radio, text, password, file (defaults to 'text'). The extended types supported by HTML5 inputs (url, email, etc.) may also be used, though using them will cause older browsers to fall back to 'text'.
The types 'file' and 'password' must be used to render those field types currently -- there are no separate Ext components for those.
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.
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.
The minimum value in pixels which this Component will set its width to.
Warning: This will override any size management applied by layout managers.
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
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'
}
})
]
});
data
and
tplWriteMode
configurations.'overwrite'
(see Ext.XTemplate.overwrite
).new Ext.Panel({
title: 'Some Title',
baseCls: 'x-component'
ui: 'green'
});
The ui configuration in this example would add 'x-component-green' as an additional class.
A custom validation function to be called during field validation (validateValue) (defaults to undefined). If specified, this function will be called first, allowing the developer to override the default validation process.
This function will be passed the following Parameters:
value
: Mixed
This function is to Return:
true
: Boolean
true
if the value is validmsg
: String
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.
Find a container above this component at any level by xtype or class
See also the up method.
Validates a value according to the field's validation rules and returns an array of errors for any failing validations. Validation rules are processed in the following order:
A validator offers a way to customize and reuse a validation specification.
If a field is configured with a validator
function, it will be passed the current field value. The validator
function is expected to return either:
If the validator
has not halted validation,
basic validation proceeds as follows:
allowBlank
: (Invalid message =
emptyText
)allowBlank
, a
blank field will cause validation to halt at this step and return
Boolean true or false accordingly.
minLength
: (Invalid message =
minLengthText
)minLength
specified, validation halts.
maxLength
: (Invalid message =
maxLengthText
)maxLength
specified, validation halts.
If none of the prior validation steps halts validation, a field
configured with a vtype
will utilize the
corresponding VTypes validation function.
If invalid, either the field's vtypeText
or
the VTypes vtype Text property will be used for the invalid message.
Keystrokes on the field will be filtered according to the VTypes
vtype Mask property.
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
Display an error message associated with this field, using msgTarget to determine how to display the message and applying invalidCls to the field's UI element.
Note: this method does not cause the Field's validate method to return false
if the value does pass validation. So simply marking a Field as invalid will not prevent
submission of forms submitted with the Ext.form.action.Action.Submit.clientValidation option set.
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()
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()
{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).Uses getErrors to build an array of validation errors. If any errors are found, markInvalid is called with the first and false is returned, otherwise true is returned.
Previously, subclasses were invited to provide an implementation of this to process validations - from 3.2 onwards getErrors should be overridden instead.
var form = new Ext.form.FormPanel({
...
items: [{
fieldLabel: 'Field 1',
name: 'field1',
allowBlank: false
},{
fieldLabel: 'Field 2',
name: 'field2',
listeners: {
specialkey: function(field, e){
// e.HOME, e.END, e.PAGE_UP, e.PAGE_DOWN,
// e.TAB, e.ESC, arrow keys: e.LEFT, e.RIGHT, e.UP, e.DOWN
if (e.getKey() == e.ENTER) {
var form = field.ownerCt.getForm();
form.submit();
}
}
}
}
],
...
});