Protected allThis is a flag to indicate whether all cells in the grid are selected or not.
Protected negativeThis contains all the current negative cell ranges in the grid.
Protected rangesThis contains all the current selected cell ranges in the grid.
The mode of selection being used. It's of type SelectionMode. Default: "single"
The type of selection being used. It's of type ExtendedSelectionType. Default: "none"
Protected silentThis is a flag to suppress the firing of selection change events.
Get notified on every change of the selection.
Protected addAdds 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.
the cells to select (adjusted in place to the selection type)
Protected adjustA copy of the current selection state, e.g. to restore it while a drag rectangle changes (see restoreSnapshot). The ranges themselves are shared – they are never changed after being added.
the state
The registered listeners (the table registers itself).
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.
Optional rowCount: numbernumber of body rows; rows >= rowCount are left out, and "all rows"
(column ranges, selectAll) becomes 0 … rowCount - 1
row indices, sorted ascending
const rowCount = tableModel.getBodyModel().getRowCount();
const rowIndices = selectionModel.getMergedRowIndices(rowCount); // e.g. [1, 2, 5]
console.log(`${rowIndices.length} rows with selected cells`);
Was everything selected with selectAll?
Protected liftRemoves 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.
the cells that are selected again
Stop notifications.
Deselects a rectangle (stored as a "negative" range, so it also cuts holes into selectAll).
For selection type "row" all rows r1 … r2 are removed, for "column" all columns c1 … c2.
A following addSelection / togglePoint of these cells selects them again.
the cells to deselect
Protected reselectSelects 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.
row index
column index
true if the cell is selected again, false if it has to be added as a new range
Restores a state created by createSnapshot (fires a change event).
the state to restore
Selects all cells. Cells that were deselected before (removeSelection) are selected again; removing cells afterwards cuts holes into "all selected".
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.
row index
column index
SelectionModelis a class that manages the various modes and types of selections within a grid. It supports basic modes like single cell, row, column, and range selections, as well as advanced mode like negative ranges. Events related to selections, such as changes to a selection, are propagated to listeners through the EventSelectionChangedListener interface.The class extends
SelectionModelIfinterface and defines additional methods and fields specific to its functionality.Method
constructor(selectionType?: ExtendedSelectionType, selectionMode?: SelectionMode) - Constructs a new instance of the SelectionModel class.
Method
getEventSelectionChangedListeners(): EventSelectionChangedListenerIf[] - Returns the array of registered event selection changed listeners.
Method
addEventSelectionChangedListener(listener: EventSelectionChangedListenerIf): void - Adds an event selection changed listener to the array.
Method
removeEventSelectionChangedListener(listener: EventSelectionChangedListenerIf): void - Removes a specific event selection changed listener if it exists.
Method
fireChangeEvent(): void - Fires a change event on each registered listener when a selection change occurs. Does nothing if the silent property is true.
Method
firstClick(rowIndex: number, columnIndex: number): void - Initiates a selection operation at the specified coordinates. The nature of the operation is determined by the current selection type and mode.
Method
getSelectionCount(rowIndex: number, columnIndex: number): number - Returns the selection count of current ranges
Method
isInNegativeRange(rowIndex: number, columnIndex: number): boolean - Verifies if any point (cell) is in negative range or not.
Method
getRanges() - Returns the selection ranges
Method
clear(): void - Clears all selections in all ranges and resets allSelected and negativeRanges arrays.
Method
hasSelection(): boolean - Checks whether there is any selection. Returns true if yes, false if no.
Method
hasNoSelection(): boolean - Checks whether there is no selection. Returns true if yes, false if no.
Method
getMergedRowIndices(rowCount?: number): number[] - Gets the sorted indices of all rows with at least one selected cell.
Method
selectAll(): void - Selects all selectable entities (also cells that were deselected before). No-op for type "none".
Method
isAllSelected() - Checks if all selectable entities are selected.
Method
addSelection(range: CellRange): void - Adds a certain range to the selection (selects removed cells again).
Method
removeSelection(range: CellRange): void - Removes a certain range from the selection.
Method
togglePoint(row: number, col: number): void - Toggles the selection state of a point at the specified row and column in a grid.
Method
isSelected(row: number, col: number): boolean - Checks if a specific cell in a grid is selected.
Method
addRange(range: CellRange): void - Adds a range of cells to the selection.