Class sap.ui.commons.Label

extends sap.ui.core.Control

Is used for labeling other controls. The API provides formatting options, for example for bold display or alignment. A label can have an icon.


Author: SAP AG.
Version: 1.2.0.
Constructor Summary
new sap.ui.commons.Label (sId?, mSettings?) Constructor for a new Label.
Method Summary
getDesign() Getter for property design.
getIcon() Getter for property icon.
getLabelFor() Association to the labeled control.
getText() Getter for property text.
getTextAlign() Getter for property textAlign.
getTextDirection() Getter for property textDirection.
getVisible() Getter for property visible.
getWidth() Getter for property width.
getWrapping() Getter for property wrapping.
setDesign(oDesign) Setter for property design.
setIcon(sIcon) Setter for property icon.
setLabelFor(vLabelFor) Association to the labeled control.
setText(sText) Setter for property text.
setTextAlign(oTextAlign) Setter for property textAlign.
setTextDirection(oTextDirection) Setter for property textDirection.
setVisible(bVisible) Setter for property visible.
setWidth(sWidth) Setter for property width.
setWrapping(bWrapping) Setter for property wrapping.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.commons.Label(sId?, mSettings?)
Constructor for a new Label.

It accepts one JSON-like object (object literal) as parameter mSettings that can define values for any property, aggregation, association or event.
If for a control a specific name is ambiguous (a property has the same name as an event), then the framework assumes property, aggregation, association, event in that order.
To resolve ambiguities, add an "aggregation:", "association:" or "event:" prefix to the key in the JSON object.
Allowed values are:

  • Properties
    • design : sap.ui.commons.LabelDesign
    • textDirection : sap.ui.core.TextDirection
    • wrapping : boolean
    • width : sap.ui.core.CSSSize
    • text : string
    • visible : boolean
    • icon : string
    • textAlign : sap.ui.core.TextAlign
  • Aggregations
    • Associations
      • labelFor : sap.ui.core.Control
    • Events
      Parameters:
      {string} sId? optional id for the new control; generated automatically if no id is given. Note: this can be omitted, no matter whether mSettings is given or not!
      {object} mSettings? optional map/JSON-object with initial values for the new control.
      Method Detail
      Getter for property design.

      Labels can have bold format.

      Default value is sap.ui.commons.LabelDesign.Standard

      Returns:
      {sap.ui.commons.LabelDesign} the value of property design
      getIcon() : string
      Getter for property icon.

      Icon to be displayed in the control.

      Default value is empty/undefined

      Returns:
      {string} the value of property icon
      getLabelFor() : string
      Association to the labeled control. By default the label set the for attribute to the ID of the labeled control. This can be changed implementing function getIdForLabel on the labelled control.
      Returns:
      {string} Id of the element which is the current target of the labelFor association, or null
      getText() : string
      Getter for property text.

      Text to be displayed.

      Default value is ''

      Returns:
      {string} the value of property text
      getTextAlign() : sap.ui.core.TextAlign
      Getter for property textAlign.

      Available alignment settings are "Begin", "Center", "End", "Left", and "Right".

      Default value is sap.ui.core.TextAlign.Begin

      Returns:
      {sap.ui.core.TextAlign} the value of property textAlign
      getTextDirection() : sap.ui.core.TextDirection
      Getter for property textDirection.

      Options for the text direction are RTL and LTR. Alternatively, the control can inherit the text direction from its parent container.

      Default value is sap.ui.core.TextDirection.Inherit

      Returns:
      {sap.ui.core.TextDirection} the value of property textDirection
      getVisible() : boolean
      Getter for property visible.

      Invisible labels are not rendered.

      Default value is true

      Returns:
      {boolean} the value of property visible
      getWidth() : sap.ui.core.CSSSize
      Getter for property width.

      Control width as common CSS-size (px or % as unit, for example).

      Default value is ''

      Returns:
      {sap.ui.core.CSSSize} the value of property width
      getWrapping() : boolean
      Getter for property wrapping.

      Specifies whether a line wrapping shall be displayed when the text value is longer than the width (feature support in preparation)

      Default value is false

      Returns:
      {boolean} the value of property wrapping
      setDesign(oDesign) : sap.ui.commons.Label
      Setter for property design.

      Default value is sap.ui.commons.LabelDesign.Standard

      Parameters:
      {sap.ui.commons.LabelDesign} oDesign new value for property design
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setIcon(sIcon) : sap.ui.commons.Label
      Setter for property icon.

      Default value is empty/undefined

      Parameters:
      {string} sIcon new value for property icon
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setLabelFor(vLabelFor) : sap.ui.commons.Label
      Association to the labeled control. By default the label set the for attribute to the ID of the labeled control. This can be changed implementing function getIdForLabel on the labelled control.
      Parameters:
      {string|sap.ui.core.Control} vLabelFor Id of an element which becomes the new target of this labelFor association. Alternatively, an element instance may be given.
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setText(sText) : sap.ui.commons.Label
      Setter for property text.

      Default value is ''

      Parameters:
      {string} sText new value for property text
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setTextAlign(oTextAlign) : sap.ui.commons.Label
      Setter for property textAlign.

      Default value is sap.ui.core.TextAlign.Begin

      Parameters:
      {sap.ui.core.TextAlign} oTextAlign new value for property textAlign
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setTextDirection(oTextDirection) : sap.ui.commons.Label
      Setter for property textDirection.

      Default value is sap.ui.core.TextDirection.Inherit

      Parameters:
      {sap.ui.core.TextDirection} oTextDirection new value for property textDirection
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setVisible(bVisible) : sap.ui.commons.Label
      Setter for property visible.

      Default value is true

      Parameters:
      {boolean} bVisible new value for property visible
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setWidth(sWidth) : sap.ui.commons.Label
      Setter for property width.

      Default value is ''

      Parameters:
      {sap.ui.core.CSSSize} sWidth new value for property width
      Returns:
      {sap.ui.commons.Label} this to allow method chaining
      setWrapping(bWrapping) : sap.ui.commons.Label
      Setter for property wrapping.

      Default value is false

      Parameters:
      {boolean} bWrapping new value for property wrapping
      Returns:
      {sap.ui.commons.Label} this to allow method chaining