Using A Formatter For The Currencies In SAPUI5
I want to build my own formattor for displaying the amount as it should in the different currencies. One could guess I use this solution I already know:
Solution 1:
If it is your intention not to show the currency symbol or code because you already show it elsewhere, you could simply set showMeasure
to false
, e.g.:
<Text xmlns:core="sap.ui.core"
core:require="{ CurrencyType: 'sap/ui/model/type/Currency' }"
text="{
parts: [
'amount',
'currency'
],
type: 'CurrencyType',
formatOptions: {
showMeasure: false
}
}"
/>
Not showing the currency code/symbol is a feature of the standard Currency type. You don't need to extend it.
Note: In case of OData V4, require the type sap/ui/model/odata/type/Currency
instead.
Solution 2:
If you want to use an custom formatter, you can define it in this way:
currency: function(amount, currency) {
var oCurrency = new sap.ui.model.type.Currency({
showMeasure: false
});
return oCurrency.formatValue([amount,curreny], "string");
}
But I would recommend to use the solution from jpenninkhof for your use case
Post a Comment for "Using A Formatter For The Currencies In SAPUI5"