How to format a number value in AngularJS ui-grid cell to two decimal?

21,028

You can use the columnDefs cellFilter option:

columnDefs: [
  {
    field: 'name',
    cellFilter: 'number: 2'
  }
]
Share:
21,028
Tony
Author by

Tony

Updated on July 09, 2022

Comments

  • Tony
    Tony almost 2 years

    I'm using Angularjs ui-grid and using the default settings, the question is how can I format the numbers to two decimal?

    enter image description here

  • Jack Song
    Jack Song about 8 years
    The question specifically asked, how to format a number value in Angular ui-grid, which requires a custom filter. While this answer is technically correct for general JavaScript usage, it is not an appropriate answer for this question.
  • Varun
    Varun about 8 years
    How to display 0 to 0.00 in ui-grid ?
  • Adrew
    Adrew over 7 years
    When I try to export my ui-grid as a pdf, the numbers still show multiple decimal points. Do you know of a way I can export my uigrid as a pdf with the data only showing two decimal?