Class sap.ui.unified.CurrencyModule: sap/ui/unified/Currency

extends Control

A text view which displays currency values and aligns them at the decimal point.

Overview

The currency control consists of an amount, which is formatted automatically according to the user’s locale (using delimiter symbols for the decimal point and thousand separators) and to the currency set for this specific number (number of decimal places).

The currency is expressed as a three-letter code.

Usage

When to use

  • To display amounts with different currencies in a vertical layout, such as in a table, list, or form, and it is important that the user is able to compare the amounts.

When not to use

  • To display amounts with the same currency in a table. Use the sap.m.ObjectNumber instead.
  • to display a number with a unit of measurement that is not a currency. Use the sap.m.ObjectNumber instead.
  • To display an amount in a structure other than a list, table, or form.

Responsive behavior

The control supports amounts smaller than 100 trillion, which still fit on a phone screen in portrait mode. For larger amounts, the unit of measurement wraps to the next line, which makes it difficult to compare the amounts.


Since: 1.21.1.
Constructor Summary
new sap.ui.unified.Currency(sId?, mSettings?)Constructor for a new Currency.
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.unified.Currency.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.unified.Currency with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.unified.Currency.getMetadata()Returns a metadata object for class sap.ui.unified.Currency.
getCurrency()Gets current value of property currency.
getCurrencySymbol()Get symbol of the currency, if available.
getFormattedValue()The formatted value.
getMaxPrecision()Gets current value of property maxPrecision.
getStringValue()Gets current value of property stringValue.
getUseSymbol()Gets current value of property useSymbol.
getValue()Gets current value of property value.
init()Initializes the control.
setCurrency(sCurrency)Sets a new value for property currency.
setMaxPrecision(iMaxPrecision)Sets a new value for property maxPrecision.
setStringValue(sStringValue)Sets a new value for property stringValue.
setUseSymbol(bUseSymbol)Sets a new value for property useSymbol.
setValue(fValue)Sets a new value for property value.
Methods borrowed from class sap.ui.base.Object
Constructor Detail
new sap.ui.unified.Currency(sId?, mSettings?)

Constructor for a new Currency.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
stringsId?ID for the new control, generated automatically if no ID is given
objectmSettings?Initial settings for the new control
Method Detail
sap.ui.unified.Currency.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.ui.unified.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.core.Control.extend.

Parameters:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.ui.unified.Currency.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.unified.Currency.
Returns:
sap.ui.base.MetadataMetadata object describing this class
getAccessibilityInfo(): Object
Returns:
ObjectCurrent accessibility state of the control.
See:
sap.ui.core.Control#getAccessibilityInfo
getCurrency(): string

Gets current value of property currency.

Determines the displayed currency code (ISO 4217).

Note: If a * character is set instead of currency code, only the character itself will be rendered, ignoring the value property.

Returns:
stringValue of property currency
getCurrencySymbol(): string
Get symbol of the currency, if available.
Returns:
string
getFormattedValue(): string
The formatted value.
Returns:
stringThe formatted value
getMaxPrecision(): int

Gets current value of property maxPrecision.

Defines the space that is available for the precision of the various currencies.

Default value is 3.

Returns:
intValue of property maxPrecision
getStringValue(): string

Gets current value of property stringValue.

Determines the currency value as a string.

String value is useful if you want to store really big values. If there are more than 21 digits before the decimal point or if the number starts with “0.” followed by more than five zeros, it is represented in exponential form. In these cases use the stringValue property to keep the number in decimal format.

Note: If set, it will take precedence over the value property.

Returns:
stringValue of property stringValue
Since:
1.54
getUseSymbol(): boolean

Gets current value of property useSymbol.

Displays the currency symbol instead of the ISO currency code.

Default value is true.

Returns:
booleanValue of property useSymbol
getValue(): float

Gets current value of property value.

Determines the currency value.

Default value is 0.

Returns:
floatValue of property value
init()
Initializes the control.
setCurrency(sCurrency): sap.ui.unified.Currency

Sets a new value for property currency.

Determines the displayed currency code (ISO 4217).

Note: If a * character is set instead of currency code, only the character itself will be rendered, ignoring the value property.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
stringsCurrencyNew value for property currency
Returns:
sap.ui.unified.CurrencyReference to this in order to allow method chaining
setMaxPrecision(iMaxPrecision): sap.ui.unified.Currency

Sets a new value for property maxPrecision.

Defines the space that is available for the precision of the various currencies.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is 3.

Parameters:
intiMaxPrecisionNew value for property maxPrecision
Returns:
sap.ui.unified.CurrencyReference to this in order to allow method chaining
setStringValue(sStringValue): sap.ui.unified.Currency

Sets a new value for property stringValue.

Determines the currency value as a string.

String value is useful if you want to store really big values. If there are more than 21 digits before the decimal point or if the number starts with “0.” followed by more than five zeros, it is represented in exponential form. In these cases use the stringValue property to keep the number in decimal format.

Note: If set, it will take precedence over the value property.

When called with a value of null or undefined, the default value of the property will be restored.

Parameters:
stringsStringValueNew value for property stringValue
Returns:
sap.ui.unified.CurrencyReference to this in order to allow method chaining
Since:
1.54
setUseSymbol(bUseSymbol): sap.ui.unified.Currency

Sets a new value for property useSymbol.

Displays the currency symbol instead of the ISO currency code.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is true.

Parameters:
booleanbUseSymbolNew value for property useSymbol
Returns:
sap.ui.unified.CurrencyReference to this in order to allow method chaining
setValue(fValue): sap.ui.unified.Currency

Sets a new value for property value.

Determines the currency value.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is 0.

Parameters:
floatfValueNew value for property value
Returns:
sap.ui.unified.CurrencyReference to this in order to allow method chaining