Ext.form.field.Field
Hierarchy
Ext.BaseExt.form.field.FieldMixed into
Files
This mixin provides a common interface for the logical behavior and state of form fields, including:
- Getter and setter methods for field values
- Events and methods for tracking value and validity changes
- Methods for triggering validation
NOTE: When implementing custom fields, it is most likely that you will want to extend the Ext.form.field.Base component class rather than using this mixin directly, as BaseField contains additional logic for generating an actual DOM complete with label and error message display and a form input field, plus methods that bind the Field value getters and setters to the input field's value.
If you do want to implement this mixin directly and don't want to extend Ext.form.field.Base, then you will most likely want to override the following methods with custom implementations: getValue, setValue, and getErrors. Other methods may be overridden as needed but their base implementations should be sufficient for common cases. You will also need to make sure that initField is called during the component's initialization.
Available since: 4.0.0
Config options
True to disable the field. Disabled Fields will not be submitted.
Defaults to: false
Available since: 4.0.0
Overrides: Ext.AbstractComponent.disabled
The name of the field. By default this is used as the parameter name when including the field value in a form submit(). To prevent the field from being included in the form submit, set submitValue to false.
Available since: 4.0.0
Setting this to false will prevent the field from being submitted even when it is not disabled.
Defaults to: true
Available since: 4.0.0
Specifies whether this field should be validated immediately whenever a change in its value is detected. If the validation results in a change in the field's validity, a validitychange event will be fired. This allows the field to show feedback about the validity of its contents immediately as the user is typing.
When set to false, feedback will not be immediate. However the form will still be validated before submitting if the clientValidation option to Ext.form.Basic.doAction is enabled, or if the field or form are validated manually.
See also Ext.form.field.Base.checkChangeEvents for controlling how changes to the field's value are detected.
Defaults to: true
Available since: 4.0.0
Properties
Flag denoting that this component is a Field. Always true.
Defaults to: true
Available since: 4.0.0
The original value of the field as configured in the value configuration, or as loaded by the last
form load operation if the form's trackResetOnLoad setting is true.
Available since: 4.0.0
Get the reference to the current class from which this object was instantiated. Unlike statics,
this.self is scope-dependent and it's meant to be used for dynamic inheritance. See statics
for a detailed comparison
Ext.define('My.Cat', {
statics: {
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
alert(this.self.speciesName); / dependent on 'this'
return this;
},
clone: function() {
return new this.self();
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
}
});
var cat = new My.Cat(); // alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
Available since: 4.0.0
Methods
Instance Methods batchChanges( fn )A utility for grouping a set of modifications which may trigger value changes into a single transaction, to
prevent e...A utility for grouping a set of modifications which may trigger value changes into a single transaction, to
prevent excessive firing of change events. This is useful for instance if the field has sub-fields which
are being updated as a group; you don't want the container field to check its own changed state for each subfield
change.
Available since: 4.0.0
Parameters
- fn : Object
A function containing the transaction code
Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: functi...Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the arguments object
Returns
- Object
Returns the result after calling the overridden method
Call the parent's overridden method. ...Call the parent's overridden method. For example:
Ext.define('My.own.A', {
constructor: function(test) {
alert(test);
}
});
Ext.define('My.own.B', {
extend: 'My.own.A',
constructor: function(test) {
alert(test);
this.callParent([test + 1]);
}
});
Ext.define('My.own.C', {
extend: 'My.own.B',
constructor: function() {
alert("Going to call parent's overriden constructor...");
this.callParent(arguments);
}
});
var a = new My.own.A(1); // alerts '1'
var b = new My.own.B(1); // alerts '1', then alerts '2'
var c = new My.own.C(2); // alerts "Going to call parent's overriden constructor..."
// alerts '2', then alerts '3'
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the arguments object
from the current method, for example: this.callParent(arguments)
Returns
- Object
Returns the result from the superclass' method
checkChange( )Checks whether the value of the field has changed since the last time it was checked. ...Checks whether the value of the field has changed since the last time it was checked.
If the value has changed, it:
- Fires the change event,
- Performs validation if the validateOnChange config is enabled, firing the
validitychange event if the validity has changed, and
- Checks the dirty state of the field and fires the dirtychange event
if it has changed.
Available since: 4.0.0
checkDirty( )Checks the isDirty state of the field and if it has changed since the last time it was checked,
fires the dirtychange...Checks the isDirty state of the field and if it has changed since the last time it was checked,
fires the dirtychange event.
Available since: 4.0.0
clearInvalid( )Clear any invalid styles/messages for this field. ...Clear any invalid styles/messages for this field. Components using this mixin should implement this method to
update the components rendering to clear any existing messages.
Note: this method does not cause the Field's validate or isValid methods to return true
if the value does not pass validation. So simply clearing a field's errors will not necessarily allow
submission of forms submitted with the Ext.form.action.Submit.clientValidation option set.
Available since: 4.0.0
extractFileInput( ) : HTMLElementOnly relevant if the instance's isFileUpload method returns true. ...Only relevant if the instance's isFileUpload method returns true. Returns a reference to the file input
DOM element holding the user's selected file. The input will be appended into the submission form and will not be
returned, so this method should also create a replacement.
Available since: 4.0.0
Returns
- HTMLElement
Runs this field's validators and returns an array of error messages for any validation failures. ...Runs this field's validators and returns an array of error messages for any validation failures. This is called
internally during validation and would not usually need to be used manually.
Each subclass should override or augment the return value to provide their own errors.
Available since: 4.0.0
Parameters
- value : Object
The value to get errors for (defaults to the current field value)
Returns
- String[]
All error messages for this field; an empty Array if none.
getModelData( ) : ObjectReturns the value(s) that should be saved to the Ext.data.Model instance for this field, when Ext.form.Basic.updateRe...Returns the value(s) that should be saved to the Ext.data.Model instance for this field, when Ext.form.Basic.updateRecord is called. Typically this will be an object with a single name-value pair, the name
being this field's name and the value being its current data value. More advanced field
implementations may return more than one name-value pair. The returned values will be saved to the corresponding
field names in the Model.
Note that the values returned from this method are not guaranteed to have been successfully validated.
Available since: 4.0.0
Returns
- Object
A mapping of submit parameter names to values; each value should be a string, or an array of
strings if that particular name has multiple values. It can also return null if there are no parameters to be
submitted.
Returns the name attribute of the field. ...Returns the name attribute of the field. This is used as the parameter name
when including the field value in a form submit().
Available since: 4.0.0
Returns
getSubmitData( ) : ObjectReturns the parameter(s) that would be included in a standard form submit for this field. ...Returns the parameter(s) that would be included in a standard form submit for this field. Typically this will be
an object with a single name-value pair, the name being this field's name and the value being
its current stringified value. More advanced field implementations may return more than one name-value pair.
Note that the values returned from this method are not guaranteed to have been successfully validated.
Available since: 4.0.0
Returns
- Object
A mapping of submit parameter names to values; each value should be a string, or an array of
strings if that particular name has multiple values. It can also return null if there are no parameters to be
submitted.
Returns the current data value of the field. ...Returns the current data value of the field. The type of value returned is particular to the type of the
particular field (e.g. a Date object for Ext.form.field.Date).
Available since: 4.0.0
Returns
- Object
value The field value
Initialize configuration for this class. ...Initialize configuration for this class. a typical example:
Ext.define('My.awesome.Class', {
// The default config
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome'
Available since: 4.0.0
Parameters
- config : Object
Returns
- Object
mixins The mixin prototypes as key - value pairs
initField( )Initializes this Field mixin on the current instance. ...Initializes this Field mixin on the current instance. Components using this mixin should call this method during
their own initialization process.
Available since: 4.0.0
initValue( )Initializes the field's value based on the initial config. ...Initializes the field's value based on the initial config.
Available since: 4.0.0
Returns true if the value of this Field has been changed from its originalValue. ...Returns true if the value of this Field has been changed from its originalValue.
Will always return false if the field is disabled.
Note that if the owning form was configured with
trackResetOnLoad then the originalValue is updated when
the values are loaded by Ext.form.Basic.setValues.
Available since: 4.0.0
Returns
- Boolean
True if this field has been changed from its original value (and is not disabled),
false otherwise.
Returns whether two field values are logically equal. ... isFileUpload( ) : BooleanReturns whether this Field is a file upload field; if it returns true, forms will use special techniques for
submitti...Returns whether this Field is a file upload field; if it returns true, forms will use special techniques for
submitting the form via AJAX. See Ext.form.Basic.hasUpload for details. If
this returns true, the extractFileInput method must also be implemented to return the corresponding file
input element.
Available since: 4.0.0
Returns
Returns whether or not the field value is currently valid by validating the field's current
value. ...Returns whether or not the field value is currently valid by validating the field's current
value. The validitychange event will not be fired; use validate instead if you want the event
to fire. Note: disabled fields are always treated as valid.
Implementations are encouraged to ensure that this method does not have side-effects such as triggering error
message display.
Available since: 4.0.0
Returns
- Boolean
True if the value is valid, else false
markInvalid( errors )Associate one or more error messages with this field. ...Associate one or more error messages with this field. Components using this mixin should implement this method to
update the component's rendering to display the messages.
Note: this method does not cause the Field's validate or isValid methods 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.Submit.clientValidation option set.
Available since: 4.0.0
Parameters
mixin( name, cls )private onChange( newVal, oldVal )privateCalled when the field's value changes. ...Called when the field's value changes. Performs validation if the validateOnChange
config is enabled, and invokes the dirty check.
Available since: 4.0.0
Parameters
reset( )Resets the current field value to the originally loaded value and clears any validation messages. ...Resets the current field value to the originally loaded value and clears any validation messages. See Ext.form.Basic.trackResetOnLoad
Available since: 4.0.0
Resets the field's originalValue property so it matches the current value. ...Resets the field's originalValue property so it matches the current value. This is
called by Ext.form.Basic.setValues if the form's
trackResetOnLoad property is set to true.
Available since: 4.0.0
Sets a data value into the field and runs the change detection and validation. ...Sets a data value into the field and runs the change detection and validation.
Available since: 4.0.0
Parameters
- value : Object
The value to set
Returns
Get the reference to the class from which this object was instantiated. ...Get the reference to the class from which this object was instantiated. Note that unlike self,
this.statics() is scope-independent and it always returns the class from which it was called, regardless of what
this points to during run-time
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
// equivalent to: My.Cat.speciesName
alert(this.self.speciesName); // dependent on 'this'
statics.totalCreated++;
return this;
},
clone: function() {
var cloned = new this.self; // dependent on 'this'
cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Available since: 4.0.0
Returns
Returns whether or not the field value is currently valid by validating the field's current
value, and fires the vali...Returns whether or not the field value is currently valid by validating the field's current
value, and fires the validitychange event if the field's validity has changed since the last validation.
Note: disabled fields are always treated as valid.
Custom implementations of this method are allowed to have side-effects such as triggering error message display.
To validate without side-effects, use isValid.
Available since: 4.0.0
Returns
- Boolean
True if the value is valid, else false
A utility for grouping a set of modifications which may trigger value changes into a single transaction, to prevent excessive firing of change events. This is useful for instance if the field has sub-fields which are being updated as a group; you don't want the container field to check its own changed state for each subfield change.
Available since: 4.0.0
Parameters
- fn : Object
A function containing the transaction code
Call the original method that was previously overridden with override
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the
argumentsobject
Returns
- Object
Returns the result after calling the overridden method
Call the parent's overridden method. For example:
Ext.define('My.own.A', {
constructor: function(test) {
alert(test);
}
});
Ext.define('My.own.B', {
extend: 'My.own.A',
constructor: function(test) {
alert(test);
this.callParent([test + 1]);
}
});
Ext.define('My.own.C', {
extend: 'My.own.B',
constructor: function() {
alert("Going to call parent's overriden constructor...");
this.callParent(arguments);
}
});
var a = new My.own.A(1); // alerts '1'
var b = new My.own.B(1); // alerts '1', then alerts '2'
var c = new My.own.C(2); // alerts "Going to call parent's overriden constructor..."
// alerts '2', then alerts '3'
Available since: 4.0.0
Parameters
- args : Array/Arguments
The arguments, either an array or the
argumentsobject from the current method, for example:this.callParent(arguments)
Returns
- Object
Returns the result from the superclass' method
Checks whether the value of the field has changed since the last time it was checked. If the value has changed, it:
- Fires the change event,
- Performs validation if the validateOnChange config is enabled, firing the validitychange event if the validity has changed, and
- Checks the dirty state of the field and fires the dirtychange event if it has changed.
Available since: 4.0.0
Checks the isDirty state of the field and if it has changed since the last time it was checked, fires the dirtychange event.
Available since: 4.0.0
Clear any invalid styles/messages for this field. Components using this mixin should implement this method to update the components rendering to clear any existing messages.
Note: this method does not cause the Field's validate or isValid methods to return true
if the value does not pass validation. So simply clearing a field's errors will not necessarily allow
submission of forms submitted with the Ext.form.action.Submit.clientValidation option set.
Available since: 4.0.0
Only relevant if the instance's isFileUpload method returns true. Returns a reference to the file input DOM element holding the user's selected file. The input will be appended into the submission form and will not be returned, so this method should also create a replacement.
Available since: 4.0.0
Returns
- HTMLElement
Runs this field's validators and returns an array of error messages for any validation failures. This is called internally during validation and would not usually need to be used manually.
Each subclass should override or augment the return value to provide their own errors.
Available since: 4.0.0
Parameters
- value : Object
The value to get errors for (defaults to the current field value)
Returns
- String[]
All error messages for this field; an empty Array if none.
Returns the value(s) that should be saved to the Ext.data.Model instance for this field, when Ext.form.Basic.updateRecord is called. Typically this will be an object with a single name-value pair, the name being this field's name and the value being its current data value. More advanced field implementations may return more than one name-value pair. The returned values will be saved to the corresponding field names in the Model.
Note that the values returned from this method are not guaranteed to have been successfully validated.
Available since: 4.0.0
Returns
- Object
A mapping of submit parameter names to values; each value should be a string, or an array of strings if that particular name has multiple values. It can also return null if there are no parameters to be submitted.
Returns the name attribute of the field. This is used as the parameter name when including the field value in a form submit().
Available since: 4.0.0
Returns
Returns the parameter(s) that would be included in a standard form submit for this field. Typically this will be an object with a single name-value pair, the name being this field's name and the value being its current stringified value. More advanced field implementations may return more than one name-value pair.
Note that the values returned from this method are not guaranteed to have been successfully validated.
Available since: 4.0.0
Returns
- Object
A mapping of submit parameter names to values; each value should be a string, or an array of strings if that particular name has multiple values. It can also return null if there are no parameters to be submitted.
Returns the current data value of the field. The type of value returned is particular to the type of the particular field (e.g. a Date object for Ext.form.field.Date).
Available since: 4.0.0
Returns
- Object
value The field value
Initialize configuration for this class. a typical example:
Ext.define('My.awesome.Class', {
// The default config
config: {
name: 'Awesome',
isAwesome: true
},
constructor: function(config) {
this.initConfig(config);
return this;
}
});
var awesome = new My.awesome.Class({
name: 'Super Awesome'
});
alert(awesome.getName()); // 'Super Awesome'
Available since: 4.0.0
Parameters
- config : Object
Returns
- Object
mixins The mixin prototypes as key - value pairs
Initializes this Field mixin on the current instance. Components using this mixin should call this method during their own initialization process.
Available since: 4.0.0
Initializes the field's value based on the initial config.
Available since: 4.0.0
Returns true if the value of this Field has been changed from its originalValue. Will always return false if the field is disabled.
Note that if the owning form was configured with trackResetOnLoad then the originalValue is updated when the values are loaded by Ext.form.Basic.setValues.
Available since: 4.0.0
Returns
- Boolean
True if this field has been changed from its original value (and is not disabled), false otherwise.
Returns whether this Field is a file upload field; if it returns true, forms will use special techniques for submitting the form via AJAX. See Ext.form.Basic.hasUpload for details. If this returns true, the extractFileInput method must also be implemented to return the corresponding file input element.
Available since: 4.0.0
Returns
Returns whether or not the field value is currently valid by validating the field's current value. The validitychange event will not be fired; use validate instead if you want the event to fire. Note: disabled fields are always treated as valid.
Implementations are encouraged to ensure that this method does not have side-effects such as triggering error message display.
Available since: 4.0.0
Returns
- Boolean
True if the value is valid, else false
Associate one or more error messages with this field. Components using this mixin should implement this method to update the component's rendering to display the messages.
Note: this method does not cause the Field's validate or isValid methods 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.Submit.clientValidation option set.
Available since: 4.0.0
Parameters
Called when the field's value changes. Performs validation if the validateOnChange config is enabled, and invokes the dirty check.
Available since: 4.0.0
Parameters
Resets the current field value to the originally loaded value and clears any validation messages. See Ext.form.Basic.trackResetOnLoad
Available since: 4.0.0
Resets the field's originalValue property so it matches the current value. This is called by Ext.form.Basic.setValues if the form's trackResetOnLoad property is set to true.
Available since: 4.0.0
Sets a data value into the field and runs the change detection and validation.
Available since: 4.0.0
Parameters
- value : Object
The value to set
Returns
Get the reference to the class from which this object was instantiated. Note that unlike self,
this.statics() is scope-independent and it always returns the class from which it was called, regardless of what
this points to during run-time
Ext.define('My.Cat', {
statics: {
totalCreated: 0,
speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
},
constructor: function() {
var statics = this.statics();
alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
// equivalent to: My.Cat.speciesName
alert(this.self.speciesName); // dependent on 'this'
statics.totalCreated++;
return this;
},
clone: function() {
var cloned = new this.self; // dependent on 'this'
cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
return cloned;
}
});
Ext.define('My.SnowLeopard', {
extend: 'My.Cat',
statics: {
speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
},
constructor: function() {
this.callParent();
}
});
var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
var clone = snowLeopard.clone();
alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
alert(clone.groupName); // alerts 'Cat'
alert(My.Cat.totalCreated); // alerts 3
Available since: 4.0.0
Returns
Returns whether or not the field value is currently valid by validating the field's current value, and fires the validitychange event if the field's validity has changed since the last validation. Note: disabled fields are always treated as valid.
Custom implementations of this method are allowed to have side-effects such as triggering error message display. To validate without side-effects, use isValid.
Available since: 4.0.0
Returns
- Boolean
True if the value is valid, else false
Static Methods Add / override static properties of this class. ...Add / override static properties of this class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Borrow another class' members to the prototype of this class. ...Borrow another class' members to the prototype of this class.
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
Available since: 4.0.2
Parameters
- fromClass : Ext.Base
The class to borrow members from
- members : String/String[]
The names of the members to borrow
Returns
- Ext.Base
this
Create a new instance of this Class. ...Create a new instance of this Class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
All parameters are passed to the constructor of the class.
Available since: 4.0.2
Returns
- Object
the created instance.
createAlias( alias, origin )staticCreate aliases for existing prototype methods. ...Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
Available since: 4.0.2
Parameters
- alias : String/Object
The new method name, or an object to set multiple aliases. See
flexSetter
- origin : String/Object
The original method name
Get the current class' name in string format. ...Get the current class' name in string format.
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
Available since: 4.0.4
Returns
- String
className
implement( members )staticAdd methods / properties to the prototype of this class. ...Add methods / properties to the prototype of this class.
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
Available since: 4.0.2
Parameters
- members : Object
Override prototype members of this class. ...Override prototype members of this class. Overridden methods can be invoked via
callOverridden
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Add / override static properties of this class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.addStatics({
someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
method2: function() { ... } // My.cool.Class.method2 = function() { ... };
});
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Borrow another class' members to the prototype of this class.
Ext.define('Bank', {
money: '$$$',
printMoney: function() {
alert('$$$$$$$');
}
});
Ext.define('Thief', {
...
});
Thief.borrow(Bank, ['money', 'printMoney']);
var steve = new Thief();
alert(steve.money); // alerts '$$$'
steve.printMoney(); // alerts '$$$$$$$'
Available since: 4.0.2
Parameters
- fromClass : Ext.Base
The class to borrow members from
- members : String/String[]
The names of the members to borrow
Returns
- Ext.Base
this
Create a new instance of this Class.
Ext.define('My.cool.Class', {
...
});
My.cool.Class.create({
someConfig: true
});
All parameters are passed to the constructor of the class.
Available since: 4.0.2
Returns
- Object
the created instance.
Create aliases for existing prototype methods. Example:
Ext.define('My.cool.Class', {
method1: function() { ... },
method2: function() { ... }
});
var test = new My.cool.Class();
My.cool.Class.createAlias({
method3: 'method1',
method4: 'method2'
});
test.method3(); // test.method1()
My.cool.Class.createAlias('method5', 'method3');
test.method5(); // test.method3() -> test.method1()
Available since: 4.0.2
Parameters
- alias : String/Object
The new method name, or an object to set multiple aliases. See flexSetter
- origin : String/Object
The original method name
Get the current class' name in string format.
Ext.define('My.cool.Class', {
constructor: function() {
alert(this.self.getName()); // alerts 'My.cool.Class'
}
});
My.cool.Class.getName(); // 'My.cool.Class'
Available since: 4.0.4
Returns
- String
className
Add methods / properties to the prototype of this class.
Ext.define('My.awesome.Cat', {
constructor: function() {
...
}
});
My.awesome.Cat.implement({
meow: function() {
alert('Meowww...');
}
});
var kitty = new My.awesome.Cat;
kitty.meow();
Available since: 4.0.2
Parameters
- members : Object
Override prototype members of this class. Overridden methods can be invoked via callOverridden
Ext.define('My.Cat', {
constructor: function() {
alert("I'm a cat!");
return this;
}
});
My.Cat.override({
constructor: function() {
alert("I'm going to be a cat!");
var instance = this.callOverridden();
alert("Meeeeoooowwww");
return instance;
}
});
var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
// alerts "I'm a cat!"
// alerts "Meeeeoooowwww"
Available since: 4.0.2
Parameters
- members : Object
Returns
- Ext.Base
this
Events
Fires when a user-initiated change is detected in the value of the field.
Available since: 4.0.0
Parameters
- this : Ext.form.field.Field
- newValue : Object
The new value
- oldValue : Object
The original value
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires when a change in the field's isDirty state is detected.
Available since: 4.0.0
Parameters
- this : Ext.form.field.Field
- isDirty : Boolean
Whether or not the field is now dirty
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.
Fires when a change in the field's validity is detected.
Available since: 4.0.0
Parameters
- this : Ext.form.field.Field
- isValid : Boolean
Whether or not the field is now valid
- eOpts : Object
The options object passed to Ext.util.Observable.addListener.