Customer numeric number in FlexGrid

Posted by: james.ingham on 8 May 2019, 3:29 pm EST

  • Posted 8 May 2019, 3:29 pm EST

    Dear Support,

    Is it possible to specify customer format for grid cells? e.g. I know I can use ‘n,’ to display a number in million, but is it possible to make it more intuitive:

    0 ~ 1000: as is

    1000 ~ 1,000,000: display letter “K” at the end

    1,000,000 ~ 1,000,000,000: display letter “M” at the end

    … and so forth

    Also, I don’t know whether I can append any arbitrary string to the format, e.g. “5 dollars”. I tried :

    c0 + ’ dollars’

    but it doesn’t work. I don’t think Wijmo documentation mentions it but is it possible?

  • Posted 9 May 2019, 10:39 pm EST

    Hi James,

    1. Display Number in Millions

      You may change the Number format by yourself using the ItemFormatter and conversion rule to convert a number to K,M and etc.

    2. You may use the custom formats and replace the $ with some other currency symbols using the following code snippet:

    <wj-flex-grid-column [binding]="'expenses'" [header]="'Expenses'" [format]="'c0&'"></wj-flex-grid-column>
    /* In your case & may be dollars*/
    

    The above solution add the dollars before the numbers. To add Dollars after the number, you need to use the itemFormatter.

    Please refer to the following demo sample for reference:

    https://stackblitz.com/edit/angular-bgh2vq?file=app/app.component.html

    Regards,

    Manish Gupta

  • Posted 16 May 2019, 3:13 pm EST

    Thanks a lot for the demo.

    I have one question: Why you use

    c0Dollar
    directly as format in one grid column, but ```

    cell.innerText = cell.innerText+" Dollars";

    
     I tried "n2Dollar" but it does not work, which seems quite confusing. Why "c0Dollar" works but "n2Dollar" format does not? Is there any documentation on the format syntax?
  • Posted 19 May 2019, 8:42 pm EST

    Hi James,

    “c0 Dollars” is the inbuilt currency custom format for column. But this prepends the Dollars to the number instead of appending. (US Culture)

    While code snippet: cell.innerText+" Dollars"; is used to append the dollars to the numbers. This does not require any formatters.

    The c0Dollar work and n2Dollar does not since it is currency dollars. Please refer to the following documentation:

    https://www.grapecity.com/wijmo/api/classes/wijmo.globalize.html#formatnumber

    Hope it clears!

    Regards,

    Manish Gupta

  • Posted 20 May 2019, 11:07 am EST - Updated 3 October 2022, 9:47 am EST

    Hi Manish,

    Thanks. The actual problem we are facing at the moment is that we want to allow users to specify their preferred format by themselves without we hard-coding any stuff (e.g. using item formatter or angular template), and many of the users want the format “Million (M)” or “Billion (B)”.

    This is particularly true when pivot grid is used. Users can change the settings but it doesn’t seem possible to specify their preferred format by themselves. See the attached image:

  • Posted 20 May 2019, 10:55 pm EST

    Hi James,

    We are sorry for the inconvenience.

    Currently, there is no format for Numbers to set in Million and Billions. We have created an enhancement request for this request with internal tracking id 380730.

    We will update you as we get an update on this.

    Regards,

    Manish Gupta

  • Posted 18 November 2019, 10:14 pm EST

    Hi James,

    We are sorry for the delayed response. Here is the developer comment regarding issue #380730

    you will be able to specify optional prefix and suffix strings in the format.

    This will allow you to write:

    Globalize.formatNumber(value, '"thousands: "c3," k"');
    > thousands: 1,234.567 k
    
    Globalize.formatNumber(value, '"millions: "c1,," M"');
    > millions: 1.2 M
    

    Thanks for the suggestion!!

    Regards,

    Manish Gupta

Need extra support?

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

Learn More

Forum Channels