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';
OptionTypeDefaultDescription
showGroupBordersbooleantrueShow borders between groups
groupHeaderRendererfunction-Custom renderer for group header content
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
MethodSignatureDescription
isGroupingActive() => booleanCheck if grouping is active
getGroups() => ColumnGroup[]Get all computed groups
getGroupColumns(groupId) => ColumnConfig[]Get columns in a specific group
refresh() => voidForce refresh of column groups
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: unknown, config: any): boolean
NameTypeDescription
rowsunknown
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.

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