Problem
getFloatFormatter and getCompactNumberFormatter in Displayer.ts build their Intl.NumberFormat from a fixed option set — min_fraction_digits/max_fraction_digits for float, a hardcoded notation: 'compact', maximumFractionDigits: 1 for compact_number — with no prefix or suffix (Displayer.ts:130-150, Displayer.ts:166-173). FloatDisplayerA and the rest of DisplayerArgs (DFWhole.ts) carry no prefix/suffix field either. No displayer composes a literal string around a formatted number.
Impact
A project styling a money column has no way to render $34.4M while keeping the underlying cell value numeric for correct grid sorting. Workarounds are both lossy: compact_number on raw-dollar-scale data gets the M suffix but never $, and converting the column to a string loses numeric sort order (AG Grid sorts on raw cell value, and a string column's raw value is the formatted text).
Suggested fix
Don't bolt prefix/suffix onto float and compact_number individually — that duplicates the same wrapping logic per numeric displayer and leaves integer out. Instead make it generic: add optional prefix/suffix string fields to the shared numeric displayer args (or to FormatterArgs itself), and apply them once in getFormatter() by wrapping whichever formatter function the existing switch already returns:
export function getFormatter(fArgs: FormatterArgs): ValueFormatterFunc<unknown> {
const base = getBaseFormatter(fArgs); // current switch(fArgs.displayer) body, unchanged
const { prefix, suffix } = fArgs as { prefix?: string; suffix?: string };
if (!prefix && !suffix) return base;
return (params) => {
const formatted = base(params);
return formatted === "" ? formatted : `${prefix ?? ""}${formatted}${suffix ?? ""}`;
};
}
That gets float, integer, and compact_number all covered in one place, is backward compatible (both default to ''/undefined), and any future numeric displayer inherits it for free.
Context
Hit while styling contract-value columns in a new tallyman project (NFL salary data, values pre-scaled to millions). Worked around for now with a derived raw-dollar column plus the existing compact_number displayer (no $).
Problem
getFloatFormatterandgetCompactNumberFormatterinDisplayer.tsbuild theirIntl.NumberFormatfrom a fixed option set —min_fraction_digits/max_fraction_digitsfor float, a hardcodednotation: 'compact', maximumFractionDigits: 1for compact_number — with no prefix or suffix (Displayer.ts:130-150,Displayer.ts:166-173).FloatDisplayerAand the rest ofDisplayerArgs(DFWhole.ts) carry noprefix/suffixfield either. No displayer composes a literal string around a formatted number.Impact
A project styling a money column has no way to render
$34.4Mwhile keeping the underlying cell value numeric for correct grid sorting. Workarounds are both lossy:compact_numberon raw-dollar-scale data gets theMsuffix but never$, and converting the column to a string loses numeric sort order (AG Grid sorts on raw cell value, and a string column's raw value is the formatted text).Suggested fix
Don't bolt
prefix/suffixontofloatandcompact_numberindividually — that duplicates the same wrapping logic per numeric displayer and leavesintegerout. Instead make it generic: add optionalprefix/suffixstring fields to the shared numeric displayer args (or toFormatterArgsitself), and apply them once ingetFormatter()by wrapping whichever formatter function the existing switch already returns:That gets
float,integer, andcompact_numberall covered in one place, is backward compatible (both default to''/undefined), and any future numeric displayer inherits it for free.Context
Hit while styling contract-value columns in a new tallyman project (NFL salary data, values pre-scaled to millions). Worked around for now with a derived raw-dollar column plus the existing
compact_numberdisplayer (no$).