mercurymedia / elm-ag-grid / AgGrid.ValueFormat

Formatting of values in the AgGrid table.

Allows to format values as currencies, decimal, and percent.

valueFormatter

currencyValueFormatter : { currency : String, countryCode : String } -> String

Format a cell value as localized CURRENCY value utilizing the Javascript Intl.NumberFormat class.

cellValue = "1200.35"

currencyValueFormatter { currency = "EUR", countryCode = "de-DE" }
> "1.200,35 €"

currencyValueFormatter { currency = "EUR", countryCode = "en-US" }
> "€1,200.35"

decimalValueFormatter : { countryCode : String, decimalPlaces : Basics.Int } -> String

Format a cell value as localized DECIMAL value utilizing the Javascript Intl.NumberFormat class.

cellValue = 1200.35

decimalValueFormatter { countryCode = "de-DE", decimalPlaces = 1 }
> "1.200,4"

decimalValueFormatter { countryCode = "en-US", decimalPlaces = 0 }
> "1,200"

percentValueFormatter : { countryCode : String, decimalPlaces : Basics.Int } -> String

Format a cell value as localized PERCENT value utilizing the Javascript Intl.NumberFormat class.

cellValue = 0.15

percentValueFormatter { countryCode = "de-DE" }
> "15%"

ValueGetter

numberValueGetter : String -> String

Casts the field value as a number.

This is important if the cell value is given as a string (e.g. for currencies) but needs to a number in order to aggregate the values.

filterValueGetter

booleanFilterValueGetter : { true : String, false : String, field : String } -> String

Format a boolean cell value with a proper translation.

This is similar to using a normal Value Getter, but is specific to the filter.

cellValue = true

booleanFilterValueGetter "boolField"
> "Yes"

numberFilterValueGetter : String -> String

Format a cell value as number.

This is similar to using a normal Value Getter, but is specific to the filter.

cellValue = "15"

numberFilterValueGetter "numberField"
> 15

dateFilterValueGetter : String -> String

Format a cell value as Date.

This is similar to using a normal Value Getter, but is specific to the filter.

cellValue = "2023-12-12"

dateFilterValueGetter "dateField"
> const date = Date("2023-12-12");
> date.setHours(0,0,0);