@jsvision/datagrid / formatAggregate
Function: formatAggregate()
formatAggregate(
spec,v,partial):string
Defined in: datagrid/src/aggregate.ts:122
Render an aggregate cell's text: "[label ][format(v) ?? String(v)]", with a trailing " (loaded)" honesty qualifier appended when partial is true and the value is present. A v === undefined (an empty avg/min/max) renders a blank cell — even with a label — so a footer never shows a bare prefix with no number.
Parameters
spec
The aggregate descriptor supplying the optional format and label.
v
number | undefined
The fold result, or undefined for an empty numeric contributor set.
partial
boolean
true when the source is not fully loaded (the total is over the loaded set only); it appends the " (loaded)" qualifier so the number is never passed off as a whole-dataset grand total.
Returns
string
The cell text, or '' when v is undefined.
Example
import { formatAggregate } from '@jsvision/datagrid';
formatAggregate({ fn: 'sum', format: (v) => `$${v.toFixed(2)}`, label: 'Σ' }, 60, false); // "Σ $60.00"
formatAggregate({ fn: 'sum', label: 'Σ' }, 60, true); // "Σ 60 (loaded)" (partial source)
formatAggregate({ fn: 'max' }, undefined, false); // "" (empty → blank)