Tagged: , ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #103657
    Rafa Esparza
    Participant

    Hi,
    i need to add a format function or something like that into smart-number-input in order to change the dot of decimal values to comma.
    ie: When i get a decimal value 25.30 i need to write into the input 25,30.
    Anyone know how could i do it?

    Thanks in advance

    #103658
    Rafa Esparza
    Participant

    i found this solution for the smart-number-input but it does not work in grids with number cell editing.

    // INPUT
    <smart-number-input 
        id="etotartic"
        [numberFormat]="{ style: 'currency', currency: 'EUR', minimumFractionDigits: 2 }" 
        (ngModelChange)="utilService.formatFunctionDotToComma('etotartic', entity.etotartic)">
    </smart-number-input>
    
    // FORMAT FUNCTION
    public formatFunctionDotToComma(fieldId: string, value: any): void {
       if (value !== ''){
         const intValue = parseFloat(value);
         document.getElementById(fieldId)?.setAttribute('value', intValue.toFixed(2).replace('.', ','));
       }
    }
    
    • This reply was modified 2 years, 2 months ago by Rafa Esparza.
    #103659
    admin
    Keymaster

    Hi Rafa,

    The formatting depends on the ‘locale’. It you set a locale which uses ‘,’ instead of ‘.’ the numbers will be formatted with it.

    Best regards,
    Peter Stoev

    Smart UI Team
    https://www.htmlelements.com/

    #103661
    Rafa Esparza
    Participant

    I use locale=”‘es'” but smart-number-input does not have decimalSeparator in the locale attributes nor input attributes.

    #103662
    admin
    Keymaster

    Hi Rafa,

    Formatting of numbers is based on the ‘locale’ setting and the numberFormat property. Smart.NumberInput uses https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat and this makes it unnecessary to have properties like decimalSeparator as it is applied automatically.

    Best regards,
    Peter Stoev

    Smart UI Team
    https://www.htmlelements.com/

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.