Skip to content
Data TableAPI Reference

Summary functions & values

comins-table@0.2.2React

comins-table root imports.

export declare function getCominsSummaryValues<TData>(rows: readonly TData[], columns: readonly CominsTableRuntimeColumn<TData>[], summary: CominsTableSummaryConfig<TData>): Record<string, React.ReactNode>;

Aggregates only the supplied rows and returns results keyed by column ID. The caller chooses pagination, filtering and Tree scope. Reads raw dotted field values without cell formatters; ignores configurations for missing columns. Does not mutate input arrays; custom aggregate/format callbacks must also be pure.

export type CominsSummaryBuiltin = "avg" | "count" | "max" | "min" | "sum";

count includes all input rows, including null, undefined and string field values. sum/avg/min/max use only finite numbers; numeric strings, NaN and Infinity are excluded. With no numeric values, the result is null, not zero.

export type CominsSummaryAggregator<TData> = (input: {
column: CominsTableRuntimeColumn<TData>;
rows: readonly TData[];
values: readonly unknown[];
}) => React.ReactNode;

column is the normalized runtime column; rows contains the supplied aggregation scope; values holds raw field values. Returns a ReactNode. Hidden, collapsed and paged scope is determined by the caller.

export type CominsSummaryFormatPayload<TData> = {
column: CominsTableRuntimeColumn<TData>;
rows: readonly TData[];
value: React.ReactNode;
values: readonly unknown[];
};

value is the computed aggregate. column/rows/values match the aggregation input. format runs after aggregation and can format output such as currency.

export type CominsSummaryColumn<TData> = CominsSummaryBuiltin | CominsSummaryAggregator<TData> | CominsSummaryColumnConfig<TData>;

Accepts a built-in name, custom function or configuration object. See table options for aggregate, format, colSpan and styling.