Class MultiRowsSelectionModel<T>

Class representing a multi-row selection model.

Type Parameters

  • T

Hierarchy

Constructors

Properties

allSelected: boolean = false

This is a flag to indicate whether all cells in the grid are selected or not.

negativeRanges: CellRange[] = []

This contains all the current negative cell ranges in the grid.

ranges: CellRange[] = []

This contains all the current selected cell ranges in the grid.

selectionMode: SelectionMode = "single"

The mode of selection being used. It's of type SelectionMode. Default: "single"

selectionType: ExtendedSelectionType = "none"

The type of selection being used. It's of type ExtendedSelectionType. Default: "none"

silent: boolean = false

This is a flag to suppress the firing of selection change events.

Methods

  • Adds a rectangle to the selection (adjusted to the selection type: whole rows for "row", whole columns for "column", the first cell for "cell"). Cells of the rectangle that were deselected before (removeSelection) are selected again – the last operation wins.

    Parameters

    • range: CellRange

      the cells to select (adjusted in place to the selection type)

    Returns void

  • The indices of all rows that contain at least one selected cell, sorted ascending and without duplicates. A row whose selected cells were all removed again (removeSelection) is left out.

    Ranges that cover all rows (selection type "column", CellRange.singleColumn: r2 = Number.MAX_SAFE_INTEGER) and selectAll can only be resolved with rowCount. Without it they are skipped (before, such a range made this method loop forever) – pass the number of (displayed) body rows to get them, too.

    Parameters

    • Optional rowCount: number

      number of body rows; rows >= rowCount are left out, and "all rows" (column ranges, selectAll) becomes 0 … rowCount - 1

    Returns number[]

    row indices, sorted ascending

    Example

    const rowCount = tableModel.getBodyModel().getRowCount();
    const rowIndices = selectionModel.getMergedRowIndices(rowCount); // e.g. [1, 2, 5]
    console.log(`${rowIndices.length} rows with selected cells`);
  • Retrieves the selected rows from an array of all table rows. The selection holds row indices of the displayed rows – pass the displayed (filtered, sorted) rows.

    Parameters

    • allrows: T[]

      The array of all rows from the table model.

    Returns T[]

    • The selected rows from the given array (the array itself if everything is selected).
  • Checks if a specific cell in a grid is selected.

    Parameters

    • row: number

      The row index of the cell to check.

    • col: number

      The column index of the cell to check.

    Returns boolean

    • Returns true if the cell is selected, otherwise false.
  • Removes the cells of range from all negative ranges ("last operation wins": cells added after they were removed are selected again). A negative range that overlaps range is split into up to four rectangles (above, below, left and right of the overlap); unbounded ranges (Number.MAX_SAFE_INTEGER) work as well.

    Parameters

    • range: CellRange

      the cells that are selected again

    Returns void

  • Selects a deselected cell again ("toggle on") by lifting the negative ranges at this cell (for selection type "row"/"column": at its whole row/column) – only possible while the cell is still inside a selected range or everything is selected. Fires no event.

    Parameters

    • row: number

      row index

    • col: number

      column index

    Returns boolean

    true if the cell is selected again, false if it has to be added as a new range

  • Toggles the selection of filtered rows. If all rows are currently selected, clears the selection. If no rows are currently selected, selects all filtered rows. Otherwise, toggles the selection of all filtered rows.

    Returns void

  • Toggles the selection state of a cell (for selection type "row"/"column": of its row/column). A cell that was deselected inside a selected range (or after selectAll) gets selected again without adding a second, overlapping range.

    Parameters

    • row: number

      row index

    • col: number

      column index

    Returns void