Skip to content

@jsvision/datagrid / fmt

Variable: fmt ​

const fmt: object

Defined in: datagrid/src/format.ts:116

The column-formatter registry. Spread a factory's result into a column({...}): format supplies the display string, and (for number/currency/percent) parse supplies the edit round-trip.

Type Declaration ​

boolean ​

boolean: (labels?, i18n?) => DisplayFormat<boolean>

Boolean → label; explicit labels win, otherwise labels come from the supplied service or English.

Parameters ​

labels? ​

Optional caller-owned labels.

false ​

string

true ​

string

i18n? ​

I18n

Optional translation service for absent labels.

Returns ​

DisplayFormat<boolean>

currency ​

currency: (o) => InvertibleFormat<number>

Locale currency (e.g. nl-NL EUR → "€ 10.000,25") + inverse (also strips the currency symbol).

Parameters ​

o ​

CurrencyFormatOptions

Returns ​

InvertibleFormat<number>

date ​

date: (o?) => DisplayFormat<CalendarDate>

Locale civil-date display for a CalendarDate. Display-only (edit via the date-picker editor).

Parameters ​

o? ​
locale? ​

string

style? ​

DateOnlyStyle

Returns ​

DisplayFormat<CalendarDate>

datetime ​

datetime: (o?) => DisplayFormat<Date>

Locale date+time display for a JS Date. Display-only.

Parameters ​

o? ​
dateStyle? ​

"short" | "medium" | "long" | "full"

locale? ​

string

timeStyle? ​

"short" | "medium" | "long" | "full"

Returns ​

DisplayFormat<Date>

enumLabel ​

enumLabel: (labels) => DisplayFormat<string>

value → label via a record map. An unknown key falls back to String(value). Display-only.

Parameters ​

labels ​

Record<string, string>

Returns ​

DisplayFormat<string>

lookupLabel ​

lookupLabel: (items) => DisplayFormat<string>

key → label via a lookup-item list. An unknown key falls back to String(value). Display-only.

Parameters ​

items ​

readonly LookupItem[]

Returns ​

DisplayFormat<string>

number ​

number: (o?) => InvertibleFormat<number>

Locale number formatter + inverse. parse strips the locale group/decimal symbols by discovery.

Parameters ​

o? ​

NumberFormatOptions

Returns ​

InvertibleFormat<number>

percent ​

percent: (o?) => InvertibleFormat<number>

Locale percent (value 0.25 → "25%") + inverse (strips the percent sign, divides by 100).

Parameters ​

o? ​

NumberFormatOptions

Returns ​

InvertibleFormat<number>

Example ​

ts
import { column, fmt } from '@jsvision/datagrid';
interface Account { balance: number; }
const balance = column<Account, number>({
  id: 'balance', title: 'Balance', align: 'right',
  value: (r) => r.balance,
  ...fmt.currency({ locale: 'nl-NL', currency: 'EUR' }), // "€ 10.000,25" + a matched inverse parse
  set: (r, v) => { r.balance = v; },
});