Skip to content

DataGridElement (Plugin API)

Internal API for plugin developers. Members marked with @internal Plugin API or using the _underscore prefix convention.

See the public API documentation for consumer-facing members.

PrefixMeaning
(none)Public API
_Protected/plugin-accessible
__Deeply internal (not documented)
EventDescriptionTriggered By
cell-activateUnified activation event (cancelable) - fires FIRST_dispatchCellClick()
cell-clickEmitted after plugins process the click, with full cell context_dispatchCellClick()
row-clickEmitted after plugins process the click, with full row context_dispatchRowClick()
PropertyTypeDescription
_rowsT[]
_headerRowElHTMLElement
_bodyElHTMLElement
_rowPoolRowElementInternal[]
_resizeControllerResizeController
_focusRownumber
_focusColnumber
_restoreFocusAfterRenderbooleanFlag to restore focus styling after next render.
_sortStateobject | unknown
_gridTemplatestring

Plugin API - called by event-delegation.ts

Dispatch cell mouse events for drag operations. Returns true if any plugin started a drag.

_dispatchCellMouseDown(event: CellMouseEvent): boolean
NameTypeDescription
eventCellMouseEvent

Dispatch cell mouse move during drag.

_dispatchCellMouseMove(event: CellMouseEvent): void
NameTypeDescription
eventCellMouseEvent

Dispatch cell mouse up to end drag.

_dispatchCellMouseUp(event: CellMouseEvent): void
NameTypeDescription
eventCellMouseEvent

Plugin API - called by rows.ts

Call afterCellRender hook on all plugins. This is called by rows.ts for each cell after it’s rendered, allowing plugins to modify cells during render rather than requiring expensive post-render DOM queries.

_afterCellRender(context: AfterCellRenderContext<T>): void
NameTypeDescription
contextAfterCellRenderContext<T>

Check if any plugin has registered an afterCellRender hook. Used to skip the hook call entirely for performance when no plugins need it.

_hasAfterCellRenderHook(): boolean

Call afterRowRender hook on all plugins that have registered for it. Called by rows.ts after each row is completely rendered.

_afterRowRender(context: AfterRowRenderContext<T>): void
NameTypeDescription
contextAfterRowRenderContext<T>Context containing row data, index, and DOM element

Check if any plugin has registered an afterRowRender hook. Used to skip the hook call entirely for performance when no plugins need it.

_hasAfterRowRenderHook(): boolean

Exposes plugin manager for event bus operations (subscribe/unsubscribe/emit). Plugins access this via this.grid._pluginManager in BaseGridPlugin.on/off/emitPluginEvent.

readonly _pluginManager: PluginManager | undefined

_columns: ColumnInternal<T>[]

Visible columns only (excludes hidden). Use for rendering.

readonly _visibleColumns: ColumnInternal<T>[]

_virtualization: VirtualState

Whether the grid is fully connected (scheduler guard).

readonly _schedulerIsConnected: boolean

The grid’s host HTMLElement. Use instead of casting grid as unknown as HTMLElement.

readonly _hostElement: HTMLElement

The grid’s render root element for DOM queries.

readonly _renderRoot: HTMLElement

Get accordion expand/collapse icons from effective config.

readonly _accordionIcons: object

Shell state for config manager shell merging.

readonly _shellState: ShellState

_emitDataChange(): void

Rebuild the row ID map for O(1) lookups. Called when rows array changes.

_rebuildRowIdMap(): void

_renderVisibleRows(start: number, end: number, epoch: number): void
NameTypeDescription
startnumber
endnumber
epochnumber

Updates ARIA row/col counts. Delegates to aria.ts module.

_updateAriaCounts(rowCount: number, colCount: number): void
NameTypeDescription
rowCountnumber
colCountnumber

Request a render at the given phase through the scheduler.

_requestSchedulerPhase(phase: number, source: string): void
NameTypeDescription
phasenumber
sourcestring

Plugin extra height for spacer calculation.

_getPluginExtraHeight(): number

Plugin-specific row height override.

_getPluginRowHeight(row: T, index: number): number | undefined
NameTypeDescription
rowT
indexnumber

Plugin extra height before a given row index.

_getPluginExtraHeightBefore(start: number): number
NameTypeDescription
startnumber

Let plugins adjust the virtual start index backwards.

_adjustPluginVirtualStart(start: number, scrollTop: number, rowHeight: number): number | undefined
NameTypeDescription
startnumber
scrollTopnumber
rowHeightnumber

Run plugin afterRender hooks.

_afterPluginRender(): void

Emit a plugin event through the plugin manager.

_emitPluginEvent(event: string, detail: unknown): void
NameTypeDescription
eventstring
detailunknown

Merge effective config (FULL/COLUMNS phase).

_schedulerMergeConfig(): void

Process columns through plugins (COLUMNS phase).

_schedulerProcessColumns(): void

Rebuild row model through plugins (ROWS phase).

_schedulerProcessRows(): void

Render header DOM (HEADER phase).

_schedulerRenderHeader(): void

Update CSS grid template (COLUMNS phase).

_schedulerUpdateTemplate(): void

Run afterRender hooks and post-render bookkeeping (STYLE phase).

_schedulerAfterRender(): void

Emit a custom event from the grid.

_emit(eventName: string, detail: unknown): void
NameTypeDescription
eventNamestring
detailunknown

Clear the row pool and body element.

_clearRowPool(): void

Run grid setup (DOM rebuild).

_setup(): void

Apply animation configuration to host element.

_applyAnimationConfig(config: GridConfig<T>): void
NameTypeDescription
configGridConfig<T>

Dispatch a cell click event to the plugin system, then emit a public event. Plugins get first chance to handle the event. After plugins process it, a cell-click CustomEvent is dispatched for external listeners.

_dispatchCellClick(event: MouseEvent, rowIndex: number, colIndex: number, cellEl: HTMLElement): boolean
NameTypeDescription
eventMouseEvent
rowIndexnumber
colIndexnumber
cellElHTMLElement

boolean - true if any plugin handled (consumed) the event, or if consumer canceled

EventDescription
cell-activateUnified activation event (cancelable) - fires FIRST
cell-clickEmitted after plugins process the click, with full cell context

Dispatch a row click event to the plugin system, then emit a public event. Plugins get first chance to handle the event. After plugins process it, a row-click CustomEvent is dispatched for external listeners.

_dispatchRowClick(event: MouseEvent, rowIndex: number, row: any, rowEl: HTMLElement): boolean
NameTypeDescription
eventMouseEvent
rowIndexnumber
rowany
rowElHTMLElement

boolean - true if any plugin handled (consumed) the event

EventDescription
row-clickEmitted after plugins process the click, with full row context

Dispatch a header click event to the plugin system. Returns true if any plugin handled the event.

_dispatchHeaderClick(event: MouseEvent | KeyboardEvent, col: ColumnConfig, headerEl: HTMLElement): boolean
NameTypeDescription
eventMouseEvent | KeyboardEvent
colColumnConfig
headerElHTMLElement

Dispatch a keyboard event to the plugin system. Returns true if any plugin handled the event.

_dispatchKeyDown(event: KeyboardEvent): boolean
NameTypeDescription
eventKeyboardEvent

Get horizontal scroll boundary offsets from plugins. Used by keyboard navigation to ensure focused cells are fully visible when plugins like pinned columns obscure part of the scroll area.

_getHorizontalScrollOffsets(rowEl: HTMLElement, focusedCell: HTMLElement): object
NameTypeDescription
rowElHTMLElement
focusedCellHTMLElement

Get a row and its current index by ID. Used internally by plugins to resolve a row’s current position in _rows after sorting, filtering, or rows replacement.

_getRowEntry(id: string): object | undefined
NameTypeDescription
idstring

Re-parse light DOM shell elements and refresh shell header. Call this after dynamically modifying <tbw-grid-header> children.

Multiple calls are batched via microtask to avoid redundant DOM rebuilds when registering multiple tool panels in sequence.

Plugin API

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