Skip to content

PinnedColumnsPlugin

Pinned Columns Plugin for tbw-grid

Freezes columns to the left or right edge of the grid—essential for keeping key identifiers or action buttons visible while scrolling through wide datasets. Just set pinned: 'left' or pinned: 'right' on your column definitions.

import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';
PropertyTypeDescription
pinned'left' | 'right' | 'start' | 'end'Pin column to edge (logical or physical)
meta.lockPinningbooleanfalse

Use logical values (start/end) for grids that work in both LTR and RTL layouts:

  • 'start' - Pins to left in LTR, right in RTL
  • 'end' - Pins to right in LTR, left in RTL
PropertyDefaultDescription
--tbw-pinned-shadow4px 0 8px rgba(0,0,0,0.1)Shadow on pinned column edge
--tbw-pinned-bordervar(--tbw-color-border)Border between pinned and scrollable
import { queryGrid } from '@toolbox-web/grid';
import { PinnedColumnsPlugin } from '@toolbox-web/grid/plugins/pinned-columns';
const grid = queryGrid('tbw-grid');
grid.gridConfig = {
columns: [
{ field: 'id', header: 'ID', pinned: 'left', width: 80 },
{ field: 'name', header: 'Name' },
{ field: 'email', header: 'Email' },
{ field: 'department', header: 'Department' },
{ field: 'actions', header: 'Actions', pinned: 'right', width: 120 },
],
plugins: [new PinnedColumnsPlugin()],
};
// Same config works in LTR and RTL
grid.gridConfig = {
columns: [
{ field: 'id', header: 'ID', pinned: 'start' }, // Left in LTR, Right in RTL
{ field: 'name', header: 'Name' },
{ field: 'actions', header: 'Actions', pinned: 'end' }, // Right in LTR, Left in RTL
],
plugins: [new PinnedColumnsPlugin()],
};

Extends BaseGridPlugin

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

Auto-detect sticky columns from column configuration.

static detect(rows: unknown, config: object): boolean
NameTypeDescription
rowsunknown
configobject

Set the pin position for a column. Updates the column’s pinned property and triggers a full re-render.

setPinPosition(field: string, position: PinnedPosition | undefined): void
NameTypeDescription
fieldstringThe field name of the column to pin/unpin
positionPinnedPosition | undefinedThe pin position ('left', 'right', 'start', 'end'), or undefined to unpin

Re-apply sticky offsets (e.g., after column resize).

refreshStickyOffsets(): void

Get columns pinned to the left (after resolving logical positions for current direction).

getLeftPinnedColumns(): ColumnConfig<any>[]

Get columns pinned to the right (after resolving logical positions for current direction).

getRightPinnedColumns(): ColumnConfig<any>[]

Clear all sticky positioning.

clearStickyPositions(): 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