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

Related questions

2 Answers

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.