Skip to content

GroupingColumnsPlugin

Column Grouping Plugin for tbw-grid

Enables visual grouping of columns under shared headers. Supports two approaches: declarative columnGroups at the grid level, or inline group property on columns.

import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';
PropertyTypeDescription
idstringUnique group identifier
headerstringDisplay label for the group header
childrenstring[]Array of column field names in this group
TypeDescription
stringSimple group ID (used as both id and label)
{ id: string; label?: string }Group object with explicit id and optional label
OptionTypeDescription
columnGroups?ColumnGroupDefinition[]Declarative column group definitions. When provided here, takes precedence over gridConfig.columnGroups.
groupHeaderRenderer?(params: GroupHeaderRenderParams) => string | void | HTMLElementGroup header renderer called for each column group. Receives the group’s id, label, and columns in the params, so a single function can handle all groups or differentiate per group via params.id.
showGroupBorders?booleanWhether to show group borders (default: true)
lockGroupOrder?booleanPrevent columns from being reordered outside their group. When enabled, column moves that would break group contiguity are blocked. Works with both header drag-and-drop and visibility panel drag-and-drop.
import '@toolbox-web/grid';
import { GroupingColumnsPlugin } from '@toolbox-web/grid/plugins/grouping-columns';
grid.gridConfig = {
columnGroups: [
{ id: 'personal', header: 'Personal Info', children: ['firstName', 'lastName', 'email'] },
{ id: 'work', header: 'Work Info', children: ['department', 'title', 'salary'] },
],
columns: [
{ field: 'firstName', header: 'First Name' },
{ field: 'lastName', header: 'Last Name' },
// ...
],
plugins: [new GroupingColumnsPlugin()],
};
grid.gridConfig = {
columns: [
{ field: 'firstName', header: 'First Name', group: { id: 'personal', label: 'Personal Info' } },
{ field: 'lastName', header: 'Last Name', group: 'personal' }, // string shorthand
],
plugins: [new GroupingColumnsPlugin()],
};

Extends BaseGridPlugin

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

Auto-detect column groups from column configuration. Detects both inline column.group properties and declarative columnGroups config.

static detect(rows: readonly any[], config: any): boolean
NameTypeDescription
rowsreadonly any[]
configany

Check if column groups are active.

isGroupingActive(): boolean

boolean - Whether grouping is active


Get the computed column groups.

getGroups(): ColumnGroup<any>[]

ColumnGroup<any>[] - Array of column groups


Get columns in a specific group (aggregated across all fragments).

getGroupColumns(groupId: string): ColumnConfig<any>[]
NameTypeDescription
groupIdstringThe group ID to find

ColumnConfig<any>[] - Array of columns in the group


Refresh column groups (recompute from current columns).

refresh(): void

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