NoxGrid Web API
    Preparing search index...

    Class NoxGrid

    NoxGrid for the web. Uses custom drawing (Canvas) to render only the visible cells.

    const grid = new NoxGrid(document.getElementById('grid')!, {
    columns: [{ name: 'name', header: 'Name' }, { name: 'age', header: 'Age', kind: 'number' }],
    rowCount: 100,
    });
    grid.setValue(0, 0, 'John Smith');
    Index
    allowColumnResize: boolean = true
    allowEdit: boolean = true
    allowFilter: boolean = false
    allowFind: boolean = true

    Find and replace via Ctrl+F, Ctrl+H, F3.

    allowSort: boolean = true
    allowUserFormulas: boolean = false

    Lets users type or paste formulas starting with = (setFormula in code works regardless).

    Columns.

    conditionalFormats: ConditionalFormatCollection

    Conditional formats.

    host: HTMLElement
    pasteAddsRows: boolean = false

    Pasting more lines than there are rows below adds rows (same undo step). Default false: extra lines are dropped (see the pasted event).

    selectionOverridesCellColors: boolean = false

    Selected cells use the selection text color instead of colors set on the cell, row, column or by conditional formats. Default false (those colors are kept, like the desktop).

    showCellToolTips: boolean = false

    Shows the whole text in a tooltip when the mouse is over a cell whose text is cut off.

    • get allowUndo(): boolean

      Enables Ctrl+Z / Ctrl+Y undo. Turning it off clears the history.

      Returns boolean

    • set allowUndo(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get alternatingRowColors(): boolean

      Alternating row colors.

      Returns boolean

    • set alternatingRowColors(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get autoHeight(): boolean

      The grid's height follows its rows, so the page scrolls instead of the grid (see GridOptions.autoHeight).

      Returns boolean

    • set autoHeight(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get canRedo(): boolean

      Returns boolean

    • get canUndo(): boolean

      Returns boolean

    • get captureFind(): "grid" | "page"

      Where Ctrl+F opens the grid's find dialog: 'grid' (when focused, default) or 'page' (anywhere, if this is the only grid on screen).

      Returns "grid" | "page"

    • set captureFind(v: "grid" | "page"): void

      Parameters

      • v: "grid" | "page"

      Returns void

    • get columnCount(): number

      Returns number

    • get columnHeadersVisible(): boolean

      Returns boolean

    • set columnHeadersVisible(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get data(): Record<string, unknown>[] | null

      The bound array of objects (the same array you passed in). Sorting changes only the screen order and never reorders this array; rows inserted or removed in the grid are inserted into or removed from it.

      Returns Record<string, unknown>[] | null

    • get emptyMessage(): string

      Text drawn in the middle of the grid when no rows are shown.

      Returns string

    • set emptyMessage(v: string): void

      Parameters

      • v: string

      Returns void

    • get footerVisible(): boolean

      Shows the footer (summary) row fixed at the bottom. Set footer on the columns.

      Returns boolean

    • set footerVisible(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get frozenColumns(): number

      Returns number

    • set frozenColumns(n: number): void

      Parameters

      • n: number

      Returns void

    • get frozenRows(): number

      Returns number

    • set frozenRows(n: number): void

      Parameters

      • n: number

      Returns void

    • get headerHeight(): number

      Returns number

    • set headerHeight(h: number): void

      Parameters

      • h: number

      Returns void

    • get hoverRow(): boolean

      Highlights the row under the mouse.

      Returns boolean

    • set hoverRow(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get maxHeight(): number

      With autoHeight: the largest height in px (0 = no limit).

      Returns number

    • set maxHeight(v: number): void

      Parameters

      • v: number

      Returns void

    • get newRowData(): (() => Record<string, unknown>) | undefined

      Bound data: the object for each new row (insertRows, pasteAddsRows).

      Returns (() => Record<string, unknown>) | undefined

    • set newRowData(fn: (() => Record<string, unknown>) | undefined): void

      Parameters

      • fn: (() => Record<string, unknown>) | undefined

      Returns void

    • get outlineLevels(): number

      Deepest group level (0 if none).

      Returns number

    • get quickFilter(): string

      Current quick filter text ('' when none).

      Returns string

    • get readOnly(): boolean

      Returns boolean

    • set readOnly(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get rowCount(): number

      Returns number

    • set rowCount(n: number): void

      Parameters

      • n: number

      Returns void

    • get rowHeadersVisible(): boolean

      Returns boolean

    • set rowHeadersVisible(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get rowHeight(): number

      Returns number

    • set rowHeight(h: number): void

      Parameters

      • h: number

      Returns void

    • get rowKey(): string | undefined

      Bound data: the field that identifies a row (GridOptions.rowKey).

      Returns string | undefined

    • set rowKey(field: string | undefined): void

      Parameters

      • field: string | undefined

      Returns void

    • get selectionKeepsBackColors(): boolean

      Selected cells keep their own background (and text color); see GridOptions.selectionKeepsBackColors.

      Returns boolean

    • set selectionKeepsBackColors(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get selectionMode(): "cell" | "fullRow"

      'cell' (default) or 'fullRow' (whole rows are selected, as the desktop FullRowSelect).

      Returns "cell" | "fullRow"

    • set selectionMode(v: "cell" | "fullRow"): void

      Parameters

      • v: "cell" | "fullRow"

      Returns void

    • get sheetName(): string | null

      Sheet name used to refer to this grid in formulas.

      Returns string | null

    • set sheetName(v: string | null): void

      Parameters

      • v: string | null

      Returns void

    • get sortCycle(): "ascDesc" | "ascDescNone"

      What clicking a header cycles through: 'ascDesc' (default) or 'ascDescNone' (third click: clearSort()).

      Returns "ascDesc" | "ascDescNone"

    • set sortCycle(v: "ascDesc" | "ascDescNone"): void

      Parameters

      • v: "ascDesc" | "ascDescNone"

      Returns void

    • get verticalGridLines(): boolean

      Vertical lines between body cells. Defaults to the color scheme's (off for modern schemes); once set, changing colorScheme keeps it.

      Returns boolean

    • set verticalGridLines(v: boolean): void

      Parameters

      • v: boolean

      Returns void

    • get visibleRowCount(): number

      Number of rows left after the column filters and the quick filter (e.g. "N results"). Hidden rows and subtotal rows are not counted; rows inside collapsed groups are. Same value as footerText's visibleRowCount.

      Returns number

    • Inserts subtotals: adds a subtotal row (SUBTOTAL formula) wherever the groupBy column value changes and groups the rows. Returns the number of rows inserted. Data must be sorted by the groupBy column (with sortFirst: true it is sorted first).

      Parameters

      • o: {
            backColor?: string;
            columns: (string | number)[];
            function?: SubtotalFunction;
            grandTotal?: boolean;
            groupBy: string | number;
            sortFirst?: boolean;
        }

      Returns number

    • Fits the column width to its contents (based on visible rows, up to 2000 rows).

      Parameters

      • col: string | number

      Returns void

    • Groups multiple changes into a single undo step.

      Type Parameters

      • T

      Parameters

      • fn: () => T

      Returns T

    • Suspends drawing (before bulk changes). Pair with endUpdate.

      Returns void

    • Gets a reference to a single cell.

      Parameters

      • row: number
      • col: string | number

      Returns CellRef

    • Returns void

    • Clears range values (a single undo step).

      Parameters

      • row: number
      • col: number
      • rowCount: number
      • colCount: number

      Returns void

    • Clears values in the selection.

      Returns void

    • Removes the sort. Bound rows go back to the order of the bound array (as the desktop ClearSort does); clearSort(false) only removes the sort indicator and keeps the current order. Undoable.

      Parameters

      • restoreOrder: boolean = true

      Returns void

    • Clears the undo history.

      Returns void

    • Collapses the group containing the row (innermost if level is omitted).

      Parameters

      • row: number
      • Optionallevel: number

      Returns boolean

    • Gets the selection as tab-separated text (formulas are remembered separately for pasting).

      Returns string

    • Index in the bound array of the object shown on a screen row (-1 when unbound). Screen rows and array indexes differ after sorting.

      Parameters

      • row: number

      Returns number

    • Destroys the grid and releases its resources.

      Returns void

    • Saves the grid as a CSV file in the browser (UTF-8 with BOM, so Excel shows Korean text correctly). Options are the same as toCsv (raw values, columns, header row, filtered rows only).

      Parameters

      • fileName: string = 'grid.csv'
      • options: CsvOptions = {}

      Returns void

    • Ends editing. commit = apply the value. Returns false and keeps editing if validation fails.

      Parameters

      • commit: boolean

      Returns boolean

    • Returns void

    • Evaluates a formula once at the current cell position (without storing it in the cell).

      Parameters

      • formula: string

      Returns CellValue

    • Parameters

      • row: number
      • Optionallevel: number

      Returns boolean

    • Finds the next matching cell and selects it. Searches visible rows and columns, wrapping from end to start.

      Parameters

      Returns CellAddress | null

    • Gives the grid input focus.

      Returns void

    • Where a cell is drawn, relative to the grid element: { x, y, width, height } (merged cells: the whole area). null when the cell is scrolled out of view or hidden; call scrollToCell(row, col) first. For automated tests and pop-ups.

      Parameters

      • row: number
      • col: string | number

      Returns { height: number; width: number; x: number; y: number } | null

    • The current colors (a copy; change them with setColors).

      Returns GridColors

    • Footer value of a column (calculated from its footer function over the rows shown by the filter; the footerValue event can change it).

      Parameters

      • col: string | number

      Returns CellValue

    • Gets the cell's formula ("=…", or null if none).

      Parameters

      • row: number
      • col: string | number

      Returns string | null

    • Where a column header is drawn, relative to the grid element (the bottom header row with multi-row headers); null when scrolled out of view.

      Parameters

      • col: string | number

      Returns { height: number; width: number; x: number; y: number } | null

    • Parameters

      • row: number

      Returns number

    • Key of a row: the rowKey field of the bound object, or the key set with setRowKey.

      Parameters

      • row: number

      Returns unknown

    • Gets the display text.

      Parameters

      • row: number
      • col: string | number

      Returns string

    • Gets the cell's validation error (null if none).

      Parameters

      • row: number
      • col: string | number

      Returns string | null

    • Parameters

      • row: number
      • col: string | number

      Returns CellValue

    • Gets range values as a 2D array.

      Parameters

      • row: number
      • col: number
      • rowCount: number
      • colCount: number

      Returns CellValue[][]

    • Groups a row range (one level deeper). Undoable.

      Parameters

      • row: number
      • row2: number

      Returns void

    • Parameters

      • row: number
      • col: string | number

      Returns boolean

    • State of a check column over the shown rows: 'on' (all checked), 'off' (none) or 'mixed'. Subtotal rows are not counted.

      Parameters

      • col: string | number

      Returns "on" | "off" | "mixed"

    • Hides the selection until the user clicks a cell or uses the keyboard in the grid (like initialSelection: 'none' at the start).

      Returns void

    • Row index (screen order) of the row with this key, -1 if none. Hidden and filtered rows are found too.

      Parameters

      • key: unknown

      Returns number

    • Parameters

      • at: number
      • count: number = 1

      Returns void

    • Schedules a redraw.

      Returns void

    • Whether the cell is read-only.

      Parameters

      • row: number
      • col: number

      Returns boolean

    • Parameters

      • col: string | number

      Returns boolean

    • Whether the row is shown: false for rows hidden with setRowVisible, filtered out by a column filter or the quick filter, or inside a collapsed group. visibleRows() lists the rows left after filtering (subtotal rows not included).

      Parameters

      • row: number

      Returns boolean

    • Parameters

      • row: number

      Returns boolean

    • Loads sheet data received from the server (columns, values, formulas, formats, merges, frozen panes). Clears the undo history.

      Parameters

      Returns void

    • Loads one sheet from workbook data (by index or name; defaults to activeSheet).

      Parameters

      Returns void

    • Merges cells.

      Parameters

      • row: number
      • col: number
      • rowSpan: number
      • colSpan: number

      Returns void

    • Type Parameters

      Parameters

      • name: K
      • fn: GridEventHandler<K>

      Returns void

    • Type Parameters

      Parameters

      • name: K
      • fn: GridEventHandler<K>

      Returns () => void

    • Opens the header filter popup.

      Parameters

      • col: number

      Returns void

    • Draws immediately (for testing).

      Returns void

    • Pastes tab-separated text starting at the current cell (a single value fills the whole selection). Returns the number of cells set.

      Parameters

      • text: string

      Returns number

    • Opens the print dialog (the browser's print preview can also save as PDF).

      Parameters

      Returns Promise<void>

    • Gets a reference to a range.

      Parameters

      • row: number
      • col: string | number
      • row2: number
      • col2: string | number

      Returns RangeRef

    • Recalculates all formulas (TODAY, RAND, etc.).

      Returns void

    • Returns boolean

    • Recalculates the footer values (after changing a column's footer settings in code).

      Returns void

    • Parameters

      • at: number
      • count: number = 1

      Returns void

    • Removes subtotal rows and ungroups. Returns the number of rows removed.

      Returns number

    • Replaces the current cell if it matches, then finds the next one (excludes read-only and formula cells).

      Parameters

      • text: string
      • replacement: string
      • options: FindOptions = {}

      Returns boolean

    • Replaces all matches (a single undo step). Returns the number of cells replaced.

      Parameters

      • text: string
      • replacement: string
      • options: FindOptions = {}

      Returns number

    • Call when the size has changed (usually automatic).

      Returns void

    • The bound object shown on a screen row (undefined when unbound).

      Parameters

      • row: number

      Returns Record<string, unknown> | undefined

    • Scrolls so the cell is visible.

      Parameters

      • row: number
      • col: string | number

      Returns void

    • Selects a cell or range.

      Parameters

      • row: number
      • col: string | number
      • Optionalrow2: number
      • Optionalcol2: string | number

      Returns void

    • Returns void

    • Checks or unchecks a check column for every row (like the desktop SetAllChecked). By default only the rows shown (not filtered out or hidden); read-only cells and subtotal rows are left as they are. One undo step. Returns the number of changed cells.

      Parameters

      • col: string | number
      • checked: boolean
      • options: { visibleOnly?: boolean } = {}

      Returns number

    • Overrides individual colors (e.g. grid.setColors({ accent: '#e11d48' })).

      Parameters

      Returns void

    • Applies a new set of column options: columns are matched by name (or field) and updated in place (their width is kept unless a width is given), new ones are added and missing ones removed, in the given order. Cell values stay.

      Parameters

      Returns void

    • Binds an array of objects (read and written via each column's field). null unbinds. keepSort: true sorts the new rows by the current sort again (for lists that are searched or reloaded).

      Parameters

      • data: Record<string, unknown>[] | null
      • options: { keepSort?: boolean } = {}

      Returns void

    • Filter: a list of values (display text) to show, or a predicate. null clears it.

      Parameters

      • col: string | number
      • filter: string[] | ((value: CellValue, row: number) => boolean) | null

      Returns void

    • Sets a formula in a cell ("=SUM(A1:A3)" or "SUM(A1:A3)"). Empty text or null clears it. Throws FormulaSyntaxError on invalid syntax.

      Parameters

      • row: number
      • col: string | number
      • formula: string | null

      Returns void

    • Keeps only rows where any of the columns (default: every visible column) contains the text (case-insensitive, as displayed). Works together with the column filters; the footer row counts the remaining rows. '' or null clears it. Safe to call while Korean text is being composed (the grid only filters).

      Parameters

      • text: string | null
      • options: { columns?: (string | number)[] } = {}

      Returns void

    • Parameters

      • row: number
      • height: number | null

      Returns void

    • Sets the key of a row (unbound grids, or bound grids without rowKey). The key follows the row when rows are inserted, removed or sorted.

      Parameters

      • row: number
      • key: unknown

      Returns void

    • Parameters

      • row: number
      • visible: boolean

      Returns void

    • Converts text to the column's kind and sets it. Throws if it cannot be converted.

      Parameters

      • row: number
      • col: string | number
      • text: string

      Returns void

    • Sets a value (undoable).

      Parameters

      • row: number
      • col: string | number
      • value: CellValue

      Returns void

    • Sets values from a 2D array in one go (a single undo step).

      Parameters

      • row: number
      • col: number
      • values: CellValue[][]

      Returns void

    • Opens the find dialog (replace = also show the replace field).

      Parameters

      • replace: boolean = false

      Returns void

    • Shows only up to level n (1 = summary only, deepest level + 1 = all).

      Parameters

      • n: number

      Returns void

    • Hint text below the cell (validation error).

      Parameters

      • row: number
      • col: number
      • message: string

      Returns void

    • Sorts by one or more columns. E.g. grid.sort([{ col: 'dept' }, { col: 'age', order: 'desc' }])

      Parameters

      • specs: { col: string | number; order?: SortOrder }[]

      Returns void

    • Header-click sort: toggles direction on the same column; with add, appends a sort column.

      Parameters

      • col: number
      • add: boolean

      Returns void

    • CSV of the display text as-is (no server needed). The first line is the header.

      Parameters

      Returns string

    • Printable HTML document (visible rows and columns, including formats and merges).

      Parameters

      Returns string

    • Sheet data to send to the server (with headerRow, headers go in the first row).

      Parameters

      • options: { headerRow?: boolean } = {}

      Returns SheetData

    • Workbook data to send to the server (a single sheet).

      Parameters

      • options: { headerRow?: boolean } = {}

      Returns WorkbookData

    • Returns boolean

    • Ungroups a row range (one level shallower).

      Parameters

      • row: number
      • row2: number

      Returns void

    • Removes merges that overlap the range.

      Parameters

      • row: number
      • col: number
      • rowSpan: number = 1
      • colSpan: number = 1

      Returns void

    • Validates all cells. Moves to the first invalid cell and returns the list of errors.

      Returns { col: number; message: string; row: number }[]

    • Row indices (screen order) of the rows counted by visibleRowCount.

      Returns number[]