Skip to Content

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

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)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 08, 2017 at 02:37 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Sep 07, 2017 at 06:33 PM

    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,

    Add comment
    10|10000 characters needed characters exceeded