Clear Up
SharpKit Reference

Labelable Interface

A mixin which allows a component to be configured and decorated with a label and/or error message as is common for form fields. This is used by e.g. Ext.form.field.Base and Ext.form.FieldContainer to let them be managed by the Field layout.

NOTE: This mixin is mainly for internal library use and most users should not need to use it directly. It is more likely you will want to use one of the component classes that import this mixin, such as Ext.form.field.Base or Ext.form.FieldContainer.

Use of this mixin does not make a component a field in the logical sense, meaning it does not provide any logic or state related to values or validation; that is handled by the related Ext.form.field.Field mixin. These two mixins may be used separately (for example Ext.form.FieldContainer is Labelable but not a Field), or in combination (for example Ext.form.field.Base implements both and has logic for connecting the two.)

Component classes which use this mixin should use the Field layout or a derivation thereof to properly size and position the label and message according to the component config. They must also call the initLabelable method during component initialization to ensure the mixin gets set up correctly.

Namespace: Ext.form

Properties

Name Description
bodyEl The div Element wrapping the component's contents. Only available after the component has been rendered.
className Defaults to: "Ext.Base"
configMap Defaults to: {}
errorEl The div Element that will contain the component's error message(s). Note that depending on the configured msgTarget, this element may be hidden in favor of some other form of presentation, but will always be present in the DOM for use by assistive technologies.
initConfigList Defaults to: []
initConfigMap Defaults to: {}
isFieldLabelable Flag denoting that this object is labelable as a field. Always true. Defaults to: true
isInstance Defaults to: true
labelCell The <TD> Element which contains the label Element for this component. Only available after the component has been rendered.
labelEl The label Element for this component. Only available after the component has been rendered.
noWrap Tells the layout system that the height can be measured immediately because the width does not need setting. Defaults to: true
self 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'
            },
            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'
            

Methods

Name Description
getActiveError() Gets the active error message for this component, if any. This does not trigger validation on its own, it merely returns any message that the component may already hold.
getActiveErrors() Gets an Array of any active error messages currently applied to the field. This does not trigger validation on its own, it merely returns any messages that the component may already hold.
getBodyColspan() Calculates the colspan value for the body cell - the cell which contains the input field. The field table structure contains 4 columns:
getFieldLabel() Returns the label for the field. Defaults to simply returning the fieldLabel config. Can be overridden to provide a custom generated label.

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

getInputId() Get the input id, if any, for this component. This is used as the "for" attribute on the label element. Implementing subclasses may also use this as e.g. the id for their own input element.
getLabelableRenderData() Generates the arguments for the field decorations rendering template.
getLabelStyle() Gets any label styling for the labelEl
getSubTplMarkup() Gets the markup to be inserted into the outer template's bodyEl. Defaults to empty string, should be implemented by classes including this mixin as needed.
hasActiveError() Tells whether the field currently has an active error message. This does not trigger validation on its own, it merely looks for any message that the component may already hold.
hasVisibleLabel() Checks if the field has a visible label
initLabelable() Performs initialization of this mixin. Component classes using this mixin should call this method during their own initialization.
renderActiveError() Updates the rendered DOM to match the current activeError. This only updates the content and attributes, you'll have to call doComponentLayout to actually update the display.
setActiveError(JsString) Sets the active error message to the given string. This replaces the entire error message contents with the given string. Also see setActiveErrors which accepts an Array of messages and formats them according to the activeErrorsTpl. Note that this only updates the error message element's text and attributes, you'll have to call doComponentLayout to actually update the field's layout to match. If the field extends Ext.form.field.Base you should call markInvalid instead.
setActiveErrors(JsArray<T>) Set the active error message to an Array of error messages. The messages are formatted into a single message string using the activeErrorsTpl. Also see setActiveError which allows setting the entire error contents with a single string. Note that this only updates the error message element's text and attributes, you'll have to call doComponentLayout to actually update the field's layout to match. If the field extends Ext.form.field.Base you should call markInvalid instead.
setFieldDefaults(object) Applies a set of default configuration values to this Labelable instance. For each of the properties in the given object, check if this component hasOwnProperty that config; if not then it's inheriting a default value from its prototype and we should apply the default value.
setFieldLabel(JsString) Set the label of this field.
trimLabelSeparator() Returns the trimmed label by slicing off the label separator character. Can be overridden.
unsetActiveError() Clears the active error message(s). Note that this only clears the error message element's text and attributes, you'll have to call doComponentLayout to actually update the field's layout to match. If the field extends Ext.form.field.Base you should call clearInvalid instead.
© Copyright 2005-2011 SharpKit. All rights reserved.