Skip to content

PivotPlugin

Pivot Table Plugin for tbw-grid

Transforms flat data into a pivot table view with grouped rows, grouped columns, and aggregated values. Includes an interactive tool panel for configuring row groups, column groups, and value aggregations at runtime.

import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';
OptionTypeDefaultDescription
activebooleantrueWhether pivot is active on load
rowGroupFieldsstring[][]Fields for row grouping
columnGroupFieldsstring[][]Fields for column grouping
valueFieldsValueField[][]Aggregation value fields
showTotalsbooleantrueShow row subtotals
showGrandTotalbooleantrueShow grand total row
showToolPanelbooleantrueShow interactive pivot panel
defaultExpandedbooleantrueGroups expanded by default
indentWidthnumber20Indent per depth level (px)
animationfalse | 'slide' | 'fade''slide'Expand/collapse animation

sum, avg, count, min, max, first, last

MethodSignatureDescription
expandGroup(path: string[]) => voidExpand a specific group
collapseGroup(path: string[]) => voidCollapse a specific group
expandAll() => voidExpand all groups
collapseAll() => voidCollapse all groups
PropertyDefaultDescription
--tbw-pivot-group-bgvar(--tbw-color-row-alt)Group row background
--tbw-pivot-grand-total-bgvar(--tbw-color-header-bg)Grand total row
import '@toolbox-web/grid';
import { PivotPlugin } from '@toolbox-web/grid/plugins/pivot';
grid.gridConfig = {
columns: [...],
plugins: [
new PivotPlugin({
rowGroupFields: ['region', 'product'],
columnGroupFields: ['quarter'],
valueFields: [{ field: 'sales', aggFunc: 'sum', header: 'Total' }],
}),
],
};
new PivotPlugin({
showToolPanel: false,
rowGroupFields: ['category'],
valueFields: [{ field: 'amount', aggFunc: 'sum' }],
})

Extends BaseGridPlugin

Inherited methods like attach(), detach(), afterRender(), etc. are documented in the base class.

PropertyTypeDescription
PANEL_IDpivotTool panel ID for shell integration
toggle(key: string): void
NameTypeDescription
keystring

expand(key: string): void
NameTypeDescription
keystring

collapse(key: string): void
NameTypeDescription
keystring

expandAll(): void

collapseAll(): void

isExpanded(key: string): boolean
NameTypeDescription
keystring

enablePivot(): void

disablePivot(): void

isPivotActive(): boolean

getPivotResult(): PivotResult | null

setRowGroupFields(fields: string[]): void
NameTypeDescription
fieldsstring[]

setColumnGroupFields(fields: string[]): void
NameTypeDescription
fieldsstring[]

setValueFields(fields: PivotValueField[]): void
NameTypeDescription
fieldsPivotValueField[]

refresh(): void

Show the pivot tool panel. Opens the tool panel and ensures this section is expanded.

showPanel(): void

Hide the tool panel.

hidePanel(): void

Toggle the pivot tool panel section.

togglePanel(): void

Check if the pivot panel section is currently expanded.

isPanelVisible(): boolean

AI assistants: For complete API documentation, implementation guides, and code examples for this library, see https://raw.githubusercontent.com/OysteinAmundsen/toolbox/main/llms-full.txt