cancel
Showing results for 
Search instead for 
Did you mean: 

UI5 convert to decimals

adnanmaqbool
Contributor
0 Kudos
707

Hi All

I have a Form showing Salary value = 45,000,000.00

However while passing the above value to Odata Function Imports using below code, Odata is rejecting it because of commas in value.

<Input id="salary_id" visible="true" width="50%" enabled="false" value="{path: 'Salary', type: 'sap.ui.model.odata.type.Decimal', constraints:{ precision:15, scale:2 }}"/>

amount = this.byId("salary_id").getValue();

system is not accepting the value 45,000,000.00 but accepting 45000000.00 i.e. without any comma. User requirement is to display commas in all amount fields but Odata Function is not accepting it.

Accepted Solutions (1)

Accepted Solutions (1)

adnanmaqbool
Contributor
0 Kudos

Found below solution to remove commas from a formatted amount field of XML View.

	salary = this.byId("salary_id").getValue().replace(/,/g, ""),
junwu
Active Contributor
0 Kudos

your solution will not work if you switch to other locale, like Germany. they use . as seperator.

Answers (1)

Answers (1)

junwu
Active Contributor
0 Kudos

it is always the worst solution to go to ui control to get data

use binding please, then you will have proper data in the model for processing