on 06-28-2020 6:49 AM
Hello all,
I got a float type value of "Amount" field in database 8,124.12 and when display this value in UI5, I got the value of 8,124.11
This is my UI5 code:
<Input
value="{path: 'AMOUNT', type: 'sap.ui.model.type.Float', formatOptions: {maxFractionDigits: 2, roundingMode: 'AWAY_FROM_ZERO', parseAsString: true, style: 'standard'}}"
valueLiveUpdate="false" maxLength="50" name="AMOUNT"/>
Amount data type definition:
{name = "AMOUNT"; sqlType = DOUBLE; comment = "Amount";},
And the value from OData:
How can I get the correct value in UI5 as in database record (which is 8,124.12 and not 8,124.11) ?
Regards,
Ferry
If the entity property "AMOUNT" has a type of "Edm.Double" (check the $metadata document), the binding type 'sap.ui.model.odata.type.Double' has to be assigned in place of Float.
value="{
path: 'AMOUNT',
type: 'sap.ui.model.odata.type.Double',
formatOptions: {
maxFractionDigits: 2,
roundingMode: 'AWAY_FROM_ZERO'
}
}"
Keep in mind that the value of "roundingMode" needs to be in lower case if the target SAPUI5 version is lower than 1.85.* I.e. 'AWAY_FROM_ZERO' → 'away_from_zero'.
___
* Related issue: https://github.com/SAP/openui5/issues/2169
See also https://stackoverflow.com/a/43946624/5846045
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you boghyon.hoffmann ! It worked as expected.
Hi there,
You have a question and need help by the community? Instead of posting into an old question thread, it is more helpful for you, if you create your own question. Here is how to get started:
That's it. Thank you!
Best regards
Your SAP Community moderator
sshanmuka Does this help? --> https://embed.plnkr.co/b32woxbQmdj5dTRu?show=view/Root.view.xml,preview:?sap-ui-xx-componentPreload=...
With a client side model (e.g. JSONModel), 'sap.ui.model.type.Float' can be used, instead of 'sap.ui.model.odata.type.Double'.
User | Count |
---|---|
74 | |
9 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.