Data Table Formatters
Ready-made formatters for DataTableHeader.format — money, plain numbers, percentages, dates, and booleans.
DataTableHeader<Order>(
key = "total",
title = "Total",
value = { it.total }, // raw, so the column sorts numerically
format = DataTableFormatters.currency(), // formatted, so the cell reads "$1,299.00"
align = TextAlign.End,
)Content copied to clipboard
Every formatter here is total: it renders null as its nullText and falls back to toString() for a value of a type it cannot handle, rather than throwing. A formatter runs during layout, once per visible cell, and an exception there would take the table down with it.
Each returned formatter holds its locale and pattern, so build it once — in a remember, or alongside the headers it belongs to — rather than per recomposition.