View as Markdown

API reference: @salmonui/pivot-table

PivotTablecomponent

import { PivotTable } from '@salmonui/pivot-table';
function PivotTable<Row = unknown>(own: PivotTableProps<Row>): ReactNode;

The pivot table.

Props: PivotTableProps

PivotTable props (71)
NameSignatureDescription
pivotoptionalpivot?: PivotController<Row> | undefined;

A shared store from usePivot(); without it the table creates its own from data, fields, pivotModel.

layoutoptionallayout?: PivotTableLayout | undefined;

compact (default): row members as a tree in one column (treegrid); tabular: one pinned column per row field.

fieldListoptionalfieldList?: boolean | 'popup' | undefined;

Built-in field list: 'popup' (or true) opens it from the toolbar and api.openFieldList().

axisBaroptionalaxisBar?: boolean | PivotAxisBarOptions | undefined;

Built-in axis bar above the table.

toolbaroptionaltoolbar?: readonly (PivotToolbarItemId | PivotToolbarItem)[] | undefined;

Built-in toolbar items above the table.

drillThroughoptionaldrillThrough?: boolean | { readonly maxRows?: number; } | undefined;

Double-click or Enter on a value cell opens its raw rows.

valueSortingoptionalvalueSorting?: boolean | { readonly multipleAxis?: boolean; } | undefined;

Value sort buttons on the leaf column headers: a click or Enter / Space on the header cycles ascending, descending, none (Shift+Enter on a header that also drills). multipleAxis (default true) sorts every row level.

editingoptionalediting?: boolean | DataGridEditing<Row> | undefined;

Editing of the drill-through grid; edits write through and re-aggregate.

pagingoptionalpaging?: boolean | { readonly rows?: number; readonly columns?: number; } | undefined;

Paging instead of virtualization (opt-in): page sizes for rows and columns. true (or {}) uses the defaults, 10 rows and 5 column members per page; an object pages only the axes it names.

aggregateOptionsoptionalaggregateOptions?: readonly PivotAggregate[] | undefined;

Aggregates offered by the value field menus.

selectionoptionalselection?: boolean | { readonly multiple?: boolean; } | undefined;

Cell selection. Default off.

emptyCellTextoptionalemptyCellText?: string | undefined;

Text of empty value cells. Default ''.

renderCelloptionalrenderCell?: ((ctx: PivotCellContext) => ReactNode) | undefined;
renderHeaderoptionalrenderHeader?: ((ctx: PivotHeaderContext) => ReactNode) | undefined;
renderTooltipoptionalrenderTooltip?: ((ctx: PivotTooltipContext) => ReactNode) | undefined;
renderLoadingoptionalrenderLoading?: ((ctx: PivotLoadingContext) => ReactNode) | undefined;
getCellClassNameoptionalgetCellClassName?: ((ctx: PivotCellContext) => string | undefined) | undefined;
onCellClickoptionalonCellClick?: ((event: PivotCellClickEvent) => void) | undefined;
persistStateoptionalpersistState?: PivotPersistState | undefined;

Saves the model in storage and restores it on mount.

exportWritersoptionalexportWriters?: PivotExportWriters | undefined;

Export writer loader: a dynamic import of the pivot subpath of the

@salmonui

/export package (Excel and PDF need it).

localeTextoptionallocaleText?: PivotLocaleText | undefined;
idoptionalid?: string | undefined;
classNameoptionalclassName?: string | undefined;
styleoptionalstyle?: CSSProperties | undefined;
aria-labeloptional'aria-label'?: string | undefined;
refoptionalref?: Ref<PivotTableApi<Row>> | undefined;
onBeforePivotModelChangeoptionalinheritedonBeforePivotModelChange?: ((event: PivotModelChangeEvent) => void);
onPivotModelChangeoptionalinheritedonPivotModelChange?: ((event: PivotModelChangeEvent) => void);
onBeforeExpandedChangeoptionalinheritedonBeforeExpandedChange?: ((event: PivotExpandedChangeEvent) => void);
onExpandedChangeoptionalinheritedonExpandedChange?: ((event: PivotExpandedChangeEvent) => void);
onBeforeFilterChangeoptionalinheritedonBeforeFilterChange?: ((event: PivotFilterChangeEvent) => void);
onFilterChangeoptionalinheritedonFilterChange?: ((event: PivotFilterChangeEvent) => void);
onBeforeSortChangeoptionalinheritedonBeforeSortChange?: ((event: PivotSortChangeEvent) => void);
onSortChangeoptionalinheritedonSortChange?: ((event: PivotSortChangeEvent) => void);
onBeforeFieldMoveoptionalinheritedonBeforeFieldMove?: ((event: PivotFieldMoveEvent) => void);
onFieldMoveoptionalinheritedonFieldMove?: ((event: PivotFieldMoveEvent) => void);
onBeforeMemberEditorOpenoptionalinheritedonBeforeMemberEditorOpen?: ((event: PivotMemberEditorOpenEvent) => void);
onBeforeAggregateMenuOpenoptionalinheritedonBeforeAggregateMenuOpen?: ((event: PivotAggregateMenuOpenEvent) => void);
onBeforeCalculatedFieldChangeoptionalinheritedonBeforeCalculatedFieldChange?: ((event: PivotCalculatedFieldChangeEvent) => void);
onCalculatedFieldChangeoptionalinheritedonCalculatedFieldChange?: ((event: PivotCalculatedFieldChangeEvent) => void);
onBeforeDrillThroughoptionalinheritedonBeforeDrillThrough?: ((event: PivotDrillThroughEvent<Row>) => void);
onDrillThroughoptionalinheritedonDrillThrough?: ((event: PivotDrillThroughEvent<Row>) => void);
onBeforeSelectionChangeoptionalinheritedonBeforeSelectionChange?: ((event: PivotSelectionChangeEvent) => void);
onSelectionChangeoptionalinheritedonSelectionChange?: ((event: PivotSelectionChangeEvent) => void);
onDataChangeoptionalinheritedonDataChange?: ((event: PivotDataChangeEvent<Row>) => void);
onComputeStartoptionalinheritedonComputeStart?: ((event: PivotComputeEvent) => void);
onComputeEndoptionalinheritedonComputeEnd?: ((event: PivotComputeEvent) => void);
onBeforeExportoptionalinheritedonBeforeExport?: ((event: PivotExportEvent) => void);
onExportoptionalinheritedonExport?: ((event: PivotExportEvent) => void);
onErroroptionalinheritedonError?: ((event: PivotErrorEvent) => void);
dataoptionalinheriteddata?: readonly Row[];

Raw rows by reference. Reactive: a new array re-aggregates (incrementally for small deltas).

fieldsoptionalinheritedfields?: readonly PivotFieldDefinition<Row>[];

Field definitions; inferred from the first rows when omitted. Read on creation.

pivotModeloptionalinheritedpivotModel?: PivotModelInput;

Reactive report model: re-applied when it changes structurally, never reset by an equal fresh literal.

defaultPivotModeloptionalinheriteddefaultPivotModel?: PivotModelInput;

Initial report model (uncontrolled).

localeoptionalinheritedlocale?: string;
customAggregatesoptionalinheritedcustomAggregates?: Readonly<Record<string, PivotCustomAggregator<unknown>>>;
getCellValueoptionalinheritedgetCellValue?: ((cell: PivotCell) => number | null);

Pure value override per cell.

workeroptionalinheritedworker?: PivotWorkerLike;

Runs the engine in this Worker (new Worker(new URL('@salmonui/pivot-table/engine/worker', import.meta.url), { type: 'module' })). Read on creation. The server renders the loading state.

deferComputeAboveoptionalinheriteddeferComputeAbove?: number;

Rows above which the first compute is deferred to the client after the first paint (the server renders the header and a loading state, aria-busy). Default 50,000.

createEngineoptionalinheritedcreateEngine?: ((options: { readonly model: unknown; readonly locale?: string | undefined; }) => unknown);

Creates the engine instead of the local one (a remote pivot source: (o) => source.createEngine(o) from createJsonPivotSource() of @salmonui/data/json). Its commands may answer asynchronously. Read on creation; the server renders the loading state.

rowHeightoptionalinheritedrowHeight?: number;
columnWidthoptionalinheritedcolumnWidth?: number;

Value column width in px. Default 120.

rowHeaderWidthoptionalinheritedrowHeaderWidth?: number;

Row header column width in px (compact) or per row field (tabular). Default 220 / 150.

heightoptionalinheritedheight?: string | number;
resizableoptionalinheritedresizable?: boolean;
reorderableoptionalinheritedreorderable?: boolean;
textWrapoptionalinheritedtextWrap?: "both" | "content" | "header" | boolean;
overflowoptionalinheritedoverflow?: "clip" | "ellipsis" | "ellipsisWithTooltip";
gridLinesoptionalinheritedgridLines?: "both" | "default" | "horizontal" | "none" | "vertical";
stripedoptionalinheritedstriped?: boolean;
highlightOnHoveroptionalinheritedhighlightOnHover?: boolean;