Skip to Content
0

How to convert string values to number format without losing dots(.) and commas (,) ?

Sep 07, 2017 at 03:27 PM

63

avatar image

Hi Experts,

I am getting integer values in the form of string from backend in the form of JSON (eg:"Price": "100,00" instead of "Price": 100,00. Price value has dots ,commas and both).

so my sorting on sap.ui.table.Table columns is not working as expected sorting is happening on strings not on integers.

How to convert string values to number format without losing dots(.) and commas (,) ?

.i.e "1.234.567,89" to 1.234.567,89 So that sorting works correctly.

I tried with parseFloat in javascript but it is ignoring dots(.) and commas (,).

sort.png (3.7 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sharath M G Sep 08, 2017 at 02:37 AM
0

The API parseFloat only works on the decimal points and not on number - thousands/millions. JSON returns strings so I am not sure if that could help you.

Implement a custom formatter to insert the commas or dots accordingly.

Regards,

Sharath

Share
10 |10000 characters needed characters left characters exceeded
Joseph BERTHE Sep 07, 2017 at 06:33 PM
0

Why do not change the type of your property ? In the Backend Server go to SEGW and select your project. Find the Entity Type and modify your property as an Integer.

Do not forget to regenerate the project and clear cache from both server (FES and BES).

Regards,

Share
10 |10000 characters needed characters left characters exceeded