class sap.ui.model.type.Unit

Control sample: sap.ui.model.type.Unit
Visiblity: public
UX Guidelines:
Implements:
Available since: N/A
Module: sap/ui/model/type/Unit
Application Component: CA-UI5-COR

This class represents the Unit composite type.


Constructor

Constructor for a Unit type.

new sap.ui.model.type.Unit(oFormatOptions?, oConstraints?, aDynamicFormatOptionNames?)
Param Type Default Value Description
oFormatOptions? object

Formatting options. For a list of all available options, see NumberFormat. If the format options showMeasure or showNumber are set to false, model messages for the respective parts are not propagated to the control, provided the corresponding binding supports the feature of ignoring model messages, see sap.ui.model.Binding#supportsIgnoreMessages, and the corresponding binding parameter is not set manually.

preserveDecimals? boolean true

By default decimals are preserved, unless oFormatOptions.style is given as "short" or "long"; since 1.89.0

source? object

Additional set of format options to be used if the property in the model is not of type string and needs formatting as well. If an empty object is given, the grouping is disabled and a dot is used as decimal separator.

oConstraints? object

Value constraints

minimum? float

Smallest value allowed for this type

maximum? float

Largest value allowed for this type

decimals? float

Largest number of decimals allowed for this type

aDynamicFormatOptionNames? array

keys for dynamic format options which are used to map additional binding values, e.g. ["decimals"]


Methods Overview

Method Description
sap.ui.model.type.Unit.extend

Creates a new subclass of class sap.ui.model.type.Unit with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.CompositeType.extend.

formatValue

Format the given array containing measure and unit code to an output value of type string. Other internal types than 'string' are not supported by the Unit type. If a source format has been defined for this type, the formatValue does also accept a string value as input, which will be parsed into an array using the source format. If vValues is not defined or null, null will be returned.

sap.ui.model.type.Unit.getMetadata

Returns a metadata object for class sap.ui.model.type.Unit.

getPartsIgnoringMessages

Gets an array of indices that determine which parts of this type shall not propagate their model messages to the attached control. Prerequisite is that the corresponding binding supports this feature, see sap.ui.model.Binding#supportsIgnoreMessages. If the format option showMeasure is set to false and the unit value is not shown in the control, the part for the unit code shall not propagate model messages to the control. Analogously, if the format option showNumber is set to false, the measure is not shown in the control and the part for the measure shall not propagate model messages to the control.

References:

  • sap.ui.model.Binding#supportsIgnoreMessages

parseValue

Parse a string value to an array containing measure and unit. Parsing of other internal types than 'string' is not supported by the Unit type. In case a source format has been defined, after parsing the Unit is formatted using the source format and a string value is returned instead.

sap.ui.model.type.Unit.extend

Creates a new subclass of class sap.ui.model.type.Unit with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.model.CompositeType.extend.

Param Type DefaultValue Description
sClassName string

Name of the class being created

oClassInfo object

Object literal with information about the class

FNMetaImpl function

Constructor function for the metadata object; if not given, it defaults to the metadata implementation used by this class

formatValue

Format the given array containing measure and unit code to an output value of type string. Other internal types than 'string' are not supported by the Unit type. If a source format has been defined for this type, the formatValue does also accept a string value as input, which will be parsed into an array using the source format. If vValues is not defined or null, null will be returned.

Param Type DefaultValue Description
vValue array string

the array of values or string value to be formatted. If an array is given, index 0 is the number value, and index 1 is the Unit code (CLDR or custom). Indices 2+ are the bound values for the dynamic format options.

sInternalType string

the target type

sap.ui.model.type.Unit.getMetadata

Returns a metadata object for class sap.ui.model.type.Unit.

getPartsIgnoringMessages

Gets an array of indices that determine which parts of this type shall not propagate their model messages to the attached control. Prerequisite is that the corresponding binding supports this feature, see sap.ui.model.Binding#supportsIgnoreMessages. If the format option showMeasure is set to false and the unit value is not shown in the control, the part for the unit code shall not propagate model messages to the control. Analogously, if the format option showNumber is set to false, the measure is not shown in the control and the part for the measure shall not propagate model messages to the control.

References:

parseValue

Parse a string value to an array containing measure and unit. Parsing of other internal types than 'string' is not supported by the Unit type. In case a source format has been defined, after parsing the Unit is formatted using the source format and a string value is returned instead.

Param Type DefaultValue Description
vValue any

the value to be parsed

sInternalType string

the source type

aCurrentValues array

Not used