Locale number format only for specific fields

Posted by: pascal.hanel on 5 July 2019, 6:55 am EST

    • Post Options:
    • Link

    Posted 5 July 2019, 6:55 am EST

    Hi all,

    I have the requirement to use the french format for some number fields in my application (having a space as thousands seperator, e.g. ‘10 000’).

    I found some solutions to programmatically implement the french locale format for specific components and later remove it again, but this caused the date pickers to also show french month names. So I couldn’t use this solution.

    Then I tried to use a pipe or patch the value with “toLocaleString(‘fr-FR’)” to the format I want, but then I got the console error Assertion failed in Wijmo: Number expected.

    Now I am a bit stuck because I have no further idea. Is there a way to set the locale number format only for a specific wj-input-number field?

    Thank you

    Pascal

  • Posted 8 July 2019, 5:07 am EST

    Hi Pascal,

    We are sorry but this feature is currently not possible in Wijmo. But, you may achieve the desired behavior by creating a custom component that inherits the WjInputNumber component. In this custom component, you change the number separator according to the culture whenever the control gets focus. Please refer to the sample below for implementation:

    https://stackblitz.com/edit/ckkyne-j8qds6

  • Posted 8 July 2019, 10:06 am EST

    Thanks a lot for your answer and the provided example!

Need extra support?

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

Learn More

Forum Channels