class sap.ui.model.type.Currency

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

This class represents the composite type Currency, which consists of the parts "amount" (of type number or string) and "currency" (of type string). In case the amount is a string, it must be the JavaScript representation of the corresponding number. If the source format option is given, the composite type has only one part of type string, holding both amount and currency in the source format.


Constructor

Constructor for a Currency type.

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

Format options; for a list of all available options, see sap.ui.core.format.NumberFormat.getCurrencyInstance. If the format options showMeasure or since 1.89.0 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

A set of format options as defined for sap.ui.core.format.NumberFormat.getCurrencyInstance which describes the format of amount and currency in the model in case the model holds this in one property of type string, e.g. as "EUR 22". If an empty object is given, grouping is disabled, the decimal separator is a dot and the grouping separator is a comma.

oConstraints? object

Constraints for the value part

minimum? number

Smallest amount allowed excluding the minimum value itself

maximum? number

Largest amount allowed excluding the maximum value itself


Methods Overview

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

Creates a new subclass of class sap.ui.model.type.Currency 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

Formats the given value to the given target type.

sap.ui.model.type.Currency.getMetadata

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

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 currency value is not shown in the control, the part for the currency code shall not propagate model messages to the control. Analogously, since 1.89.0, if the format option showNumber is set to false, the amount is not shown in the control and the part for the amount shall not propagate model messages to the control.

References:

  • sap.ui.model.Binding#supportsIgnoreMessages

parseValue

Parses a string value.

sap.ui.model.type.Currency.extend

Creates a new subclass of class sap.ui.model.type.Currency 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

Formats the given value to the given target type.

Param Type DefaultValue Description
vValue any[] string

The array containing amount and currency code in case the source format option is not given; otherwise, a string representation of the value which is parsed using the source format

sTargetType string

The target type; must be "string", or a type with "string" as its primitive type

sap.ui.model.type.Currency.getMetadata

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

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 currency value is not shown in the control, the part for the currency code shall not propagate model messages to the control. Analogously, since 1.89.0, if the format option showNumber is set to false, the amount is not shown in the control and the part for the amount shall not propagate model messages to the control.

References:

parseValue

Parses a string value.

Param Type DefaultValue Description
sValue string

The value to be parsed

sSourceType string

The source type (the expected type of sValue); must be "string", or a type with "string" as its primitive type.

aCurrentValues array

Not used