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.
Installation
Section titled “Installation”import { ColumnVirtualizationPlugin } from '@toolbox-web/grid/plugins/column-virtualization';Configuration Options
Section titled “Configuration Options”| Option | Type | Default | Description |
|---|---|---|---|
autoEnable | boolean | true | Auto-enable when column count exceeds threshold |
threshold | number | 30 | Column count threshold for auto-enable |
overscan | number | 3 | Extra columns to render beyond visible |
Requirements
Section titled “Requirements”- Grid must use
fitMode: 'fixed' - Columns must have explicit widths
- Grid must have fixed height
Programmatic API
Section titled “Programmatic API”| Method | Signature | Description |
|---|---|---|
isEnabled | () => boolean | Check if virtualization is active |
setEnabled | (enabled: boolean) => void | Enable/disable virtualization |
getVisibleRange | () => { start, end } | Get visible column range |
Example
Section titled “Example”Wide Grid with Column Virtualization
Section titled “Wide Grid with Column Virtualization”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 }), ],};See Also
Section titled “See Also”ColumnVirtualizationConfigfor configuration options
Extends BaseGridPlugin
Inherited methods like
attach(),detach(),afterRender(), etc. are documented in the base class.
Methods
Section titled “Methods”getIsVirtualized()
Section titled “getIsVirtualized()”Check if column virtualization is currently active.
getIsVirtualized(): booleangetVisibleColumnRange()
Section titled “getVisibleColumnRange()”Get the current visible column range.
getVisibleColumnRange(): objectscrollToColumn()
Section titled “scrollToColumn()”Scroll the grid to bring a specific column into view.
scrollToColumn(columnIndex: number): voidParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
columnIndex | number | Index of the column to scroll to |
getColumnOffset()
Section titled “getColumnOffset()”Get the left offset for a specific column.
getColumnOffset(columnIndex: number): numberParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
columnIndex | number | Index of the column |
getTotalWidth()
Section titled “getTotalWidth()”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