How Do I Format a Number in a Column?
This Lesson presents how to format a number in a Data Grid column, using the Data Grid Helper Plugin (DGH).
Installing the Numbers Formatting Script from the DGH's Script Installer
Building Columns in the Columns Builder Preview
Adding Of A Custom Script In A Column
Formatting the column
Open the Column Builder's Format topic. (2)
In this column, we would like to have:
- numbers truncated to two decimals
- negative numbers in red, without the negative sign
- a comma as the thousands separator
In the Pattern property, type this pattern:
### ### ##0.00,### ### ##0.00[red]
Note the pattern is possibily divided in three items:
- the first for positive numbers
- the second for negative numbers
- the last for Zero values
For more information about how to build a formatting pattern, please follow this lesson:
In the Thousands Separtor property, type a comma.
Using DGH To Build The Required Script
Confirming the warning message
Testing The Result In The Column Builder Preview
Before to validate our work on the Sales Amount column, this is better to test how our column will be presented.
In the Column Builder Preview, you can input some amounts in the three preview cells available for a column:
1742.375 in the first line.
-125 in the second line.
3174987.5 in the last line.
By doing that, you have probably noticed the number is formatted when the cell is closed, and that it reappears at its initial input when one edits it again.
That is because the format applied is a displaying format. It change only how the number is represented, and keeps the number unchanged in the data. This leaves the possibility of to continue sorting the column or to apply some calcul to the amounts such as doing sums.