Skip to content

Core Concepts

NextGrid separates static configuration from mutable runtime state and keeps every mutation atomic. Understanding these core concepts makes advanced features predictable.

  • columnDefs describe schema and behavior (key, valueGetter, formatter, isSortable, cellEditor).
  • ColumnState holds runtime user layout (width, isVisible, pinned, flex, display order) exposed by getColumnState().

When you call setColumnDefs(nextDefs), NextGrid matches kept columns by colId so user widths, pins, visibility, and order survive schema updates.

  • sourceIndex: A row’s 0-based index in the original rowData or rowSource.
  • displayIndex: A row’s current visual position after filtering, sorting, pagination, grouping, or tree expansion.
  • rowId: The stable string returned by getRowId, rowKey, or generateRowId.

APIs accept RowAddress ({ rowId } or { displayIndex }). Persistent selection and detail expansion always track rowId (never displayIndex) so reordering data never selects the wrong row.

Every dataset replacement (setRowData, setRowSource) starts a new dataEpoch string. Stale edits, async row transactions, or clipboard operations captured under an older epoch are rejected safely instead of writing into a newly loaded row. See Row Identity & Epochs.

Every event in GridEventMap carries:

  • source: 'api' | 'ui' | 'stateRestore' | 'datasource' so listeners can distinguish user clicks from programmatic updates and avoid feedback loops.
  • state: the committed v5 GridState snapshot.
  • Monotonic counters (transactionVersion, modelVersion, layoutVersion, focusVersion, selectionVersion).

State updates (applyState, setColumnDefs, applyRowTransaction, setCellSpans, setHierarchyOptions) validate all invariants before publishing. If validation fails, the grid throws and leaves its prior committed state untouched—never half-applied.

Construction-Only vs. Runtime-Mutable Options

Section titled “Construction-Only vs. Runtime-Mutable Options”

Options such as density, direction, localeText, rowHeight, rowOverscan, modules, and rowModelType are read once at construction. Options with setters (columnDefs, rowData, theme, pivot, pinnedRows, cellSpans, etc.) update the live grid without recreating DOM pools. See the Mutable via column in GridOptions.

Modularity (next-grid-js vs next-grid-js/core)

Section titled “Modularity (next-grid-js vs next-grid-js/core)”

next-grid-js bundles all features. next-grid-js/core omits optional modules (ExportModule, ClipboardModule) so applications register only what they need per instance via modules. See Entries & Modules.