Skip to contents

Set aggrid Columns format

Usage

ag_col_format(x, columns, format)

Arguments

x

aggrid Object

columns

Specify the column to modify, Default is all columns.

format

use numeraljs format

Examples

data.frame(
  price = c(9603.01, 100, 98322),
  percent = c(0.9525556, 0.5, 0.112),
  exponential = c(123456789, 0.0001314, 0.52),
  bytes = c(1024^3, 1024^2, 1024)
) |>
  aggrid() |>
  ag_col_format(price, "$0,0.000") |>
  ag_col_format(percent, "0.0%") |>
  ag_col_format(exponential, "0,0e+0") |>
  ag_col_format(bytes, "0 b")
# custom valueFormatter data.frame( Area = c(1000, 200, 40) ) |> aggrid() |> ag_col_def(valueFormatter = JS(' (params) => {return params.value + " mi\u00b2";}; ')) #> Error in JS("\n (params) => {return params.value + \" mi²\";};\n "): could not find function "JS"