Skip to content

Integers and decimals

Use whole-number display for inventory, seats, and event counts; use decimal display for weights, prices, and scores. This recipe uses the Pro formatting setup.

grid.source = [{ count: 1234, weight: 12.3456 }];
grid.columns = [
{ prop: 'count', name: 'Count', dataGridFormat: {
value: { kind: 'preset', preset: 'number', locale: 'en-US', decimalPlaces: 0 },
} },
{ prop: 'weight', name: 'Weight (kg)', dataGridFormat: {
value: { kind: 'preset', preset: 'number', locale: 'en-US', decimalPlaces: 2 },
} },
];

The displays are 1,234 and 12.35; the source weight remains 12.3456. Set useGrouping: false to remove grouping separators. Setting zero decimal places rounds the display; it does not validate integer input.

Put these properties inside dataGridFormat.value with kind: 'preset':

PropertySupported values / behavior
presetautomatic, number, currency, accounting, percent, scientific, date, datetime, time, text
localeBCP 47 locale such as de-DE; omitted uses runtime locale; invalid locale falls back to runtime default
decimalPlacesFixed fraction digits; truncated and clamped to 0–20; numeric formatting defaults to 2
useGroupingBoolean; numeric formatting defaults to true
currencyCurrency code for currency/accounting; defaults/falls back to USD for malformed codes
negativeStyleminus, parentheses, red; accounting uses locale accounting conventions; red is presentation styling
dateStyleshort, medium, long, full for date/datetime
timeStyleshort, medium, long for time/datetime
timeZoneIntl time zone for date/time display

automatic preserves the scalar’s normal string representation; it is not localized numeric formatting. text displays a string representation and does not change source types. Date options do not apply to numeric presets. Compact notation, significant digits, unit display and custom rounding modes are not preset properties: use Intl templates.

null and undefined display blank. Zero remains a number, distinct from missing data. Numeric presets accept finite numbers and canonical numeric strings such as "12.5" or "1e3"; this display coercion does not convert the source for numeric operations. Localized strings such as "1.234,50" are not parsed. NaN, infinity and nonnumeric text fall back to their string form. Normalize input before assigning source rows.

JavaScript numbers use binary floating point. Displaying two decimals cannot make financial arithmetic exact or recover an integer already rounded outside the safe integer range. Use an appropriate exact representation/calculation layer for money and large identifiers. BigInt can display through numeric presets, but this does not establish compatibility with every grid editor, formula, filter, aggregation, or JSON transport.

For optional decimals and rational fractions, use format codes. For minimum/maximum rules and integer enforcement, use editing and validation.