Skip to content

ColumnVirtualizationPlugin

Column Virtualization Plugin for tbw-grid

Provides horizontal column virtualization for grids with many columns (30+). Only renders visible columns plus overscan, significantly improving rendering performance for wide grids.

import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';
OptionTypeDefaultDescription
autoEnablebooleantrueAuto-enable when column count exceeds threshold
thresholdnumber30Column count threshold for auto-enable
overscannumber3Extra columns to render beyond visible
  • Grid must use fitMode: 'fixed'
  • Columns must have explicit widths
  • Grid must have fixed height
MethodSignatureDescription
isEnabled() => booleanCheck if virtualization is active
setEnabled(enabled: boolean) => voidEnable/disable virtualization
getVisibleRange() => { start, end }Get visible column range
import '@toolbox-web/grid';
import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';
grid.gridConfig = {
columns: generateManyColumns(100), // 100 columns
fitMode: 'fixed', // Required
plugins: [
new ColumnVirtualizationPlugin({
threshold: 30, // Enable when >30 columns
overscan: 3, // Render 3 extra columns each side
}),
],
};

Extends BaseGridPlugin

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

Check if column virtualization is currently active.

getIsVirtualized(): boolean

Get the current visible column range.

getVisibleColumnRange(): object

Scroll the grid to bring a specific column into view.

scrollToColumn(columnIndex: number): void
NameTypeDescription
columnIndexnumberIndex of the column to scroll to

Get the left offset for a specific column.

getColumnOffset(columnIndex: number): number
NameTypeDescription
columnIndexnumberIndex of the column

Get the total width of all columns.

getTotalWidth(): number

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