Get notified on every change of the selection.
Adds a rectangle to the selection, e.g. new CellRange(0, 0, 9, 3) (rows 0–9, columns 0–3).
Cells removed before (removeSelection) are selected again – the last operation wins.
The registered listeners (the table registers itself).
The indices of all rows that contain at least one selected cell, sorted ascending.
Ranges that cover all rows (selection type "column") and selectAll need rowCount to be listed;
without it they are skipped. Implementations written before rowCount existed may ignore it.
Optional rowCount: numbernumber of body rows (optional): limits the result to 0 … rowCount - 1
const sm = tableApi.getSelectionModel();
const rowIndices = sm?.getMergedRowIndices(tableModel.getBodyModel().getRowCount()) ?? [];
Was everything selected with selectAll?
Stop notifications.
Removes a rectangle from the selection (also from "all selected"); a later addSelection selects it again.
What is selected in a table – a list of rectangles (CellRange). The implementation is SelectionModel; every table gets its own, or you pass one via TableOptionsIf.getSelectionModel. Changes are reported to EventListenerIf.onSelectionChanged.
Example
See
Training: Select cells, rows and ranges – and copy them