Wijmo InputNumber decimal rounding

Posted by: fergus.brown on 1 July 2024, 11:17 am EST

    • Post Options:
    • Link

    Posted 1 July 2024, 11:17 am EST

    Hello,

    We have been looking to utilise wijmo inputnumber for one of our grids.

    We want to allow input of & display 3 decimal places. We’ve achived this using n3 format. However, when loading the saved response from the database - the value is getting rounded up. I.e, 87.378 would display as 87.380. I have attempted to attach a visual example of this, however the uploader does not seem to be working.

    This is reproducible within the documentation. https://developer.mescius.com/wijmo/demos/Input/InputNumber/Overview/angular - if you change ‘theValue’ on line 17 of app.component.ts to 87.378 (or similar 3 d.p number), and change line 7 of app.component.html to include [format]=“‘n3’” and rerun you can see the incorrect value displaying in the box.

    Is this intentional behaviour? It feels like an oversight to allow for nX formats but to not properly display them. If it is intentional, are there any workarounds/potential fixes?

    Thanks

  • Posted 2 July 2024, 8:05 am EST

    Hi Fergus,

    It seems like you are setting the format property after initializing the value. If that’s the case, the observed behavior will occur because the value has already been rounded off as per the internal format by the time the format is initialized.

    To resolve the issue, please set the [format]=“‘n3’” before initializing the value in the .HTML file. Please refer to the code snippet below for reference:

    <wj-input-number [format]="'n3'" [(value)]="theValue" id="theNumber"></wj-input-number>

    Sample link: https://jscodemine.mescius.io/sample/D-wXbL1H9UGmqjmPvpsbSA/

    Regards

  • Posted 3 July 2024, 4:16 am EST

    Thanks so much - I had no idea that attribute order impacted the initialization - much appreciated.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels