Performance Guide
Follow these patterns to preserve NextGrid’s O(viewport) rendering and avoid unnecessary work on the main thread:
Checklist
Section titled “Checklist”- Always provide stable row identity (
getRowId/rowKey): Enables incremental transactions (applyRowTransaction), avoids re-creating selection state, and prevents stale edit races. - Memoize
columnDefs: In React, Vue, Svelte, and Angular, pass stableColumnDefobject references (useMemo,computed,$derived, class fields) sosetColumnDefsdoes not re-run client sorting/filtering or recreate renderers on every render. - Prefer
applyRowTransactionoversetRowData: ReplacingrowDatabumpsdataEpoch, clears undo history, and recreates cell renderers; transactions update only affected rows. - Batch high-frequency updates with
applyRowTransactionAsync: Coalesces bursts into one animation-frame commit. - Implement
update(params)returningtrueincellRenderer: Cells scroll through recycled DOM pools; returningtrueupdates text/styles in place instead of destroying and recreating elements every scroll frame. - Keep
formatter,valueGetter, andisMastercheap and pure: These run across visible/sampled cells and during sorting/filtering. - Use
RowSourceor Remote/Viewport Models for 100k+ rows: Avoid materializing huge client arrays when lazy indexing (rowSource) or block-cached server pagination (infinite/serverSide) fits better.