DataGridXL - API

CellSelector

Description

The CellSelector is responsible for anything related to your cell selection inside your DataGridXL instance. It is bound to a Sheet instance.

Usage

Your DataGridXL instance contains a property cellSelector.

javascript
// create DataGridXL instance
const grid = new DataGridXL(...);
// work with the CellSelector instance
grid.cellSelector.selectAll();
grid.cellSelector.events.on('change', ...);
NOTE: You don't need to create a CellSelector instance yourself — it is provided by the grid automatically.

Methods

addCellRangeToSelection(cellRange)

Add cell range to selection

Arguments

cellRange
CellRange
Fires$change
addColRangeToSelection(colRange, cellCursorRowCoord?)

Add column range to selection

Arguments

colRange
ColRangeColumn range
cellCursorRowCoord?
RowCoorddefault 0Row coordinate of cell cursor
Fires$change
addRowRangeToSelection(rowRange, cellCursorColCoord?)

Add row range to selection

Arguments

rowRange
RowRange
cellCursorColCoord?
ColCoorddefault 0Column coordinate of cell cursor
Fires$change
clear()

Clear any selection

Fires$change
getActiveSelectionRange(): SelectionRange

The current active selection range

ReturnsSelectionRange
getCellCursorPosition(): CellCoords

The current cell cursor position

ReturnsCellCoordsCell coordinates of cell cursor
getColTypeSelectionRanges(colCoord?): array<SelectionRange>

All selection ranges of type `col` Pass a column coordinate to only return selection ranges that span the given column

Arguments

colCoord?
ColCoorddefault nullColumn Coordinate
Returnsarray<SelectionRange>List of selection ranges
getRowTypeSelectionRanges(rowCoord?): array<SelectionRange>

All selection ranges of type `row` Pass a row coordinate to only return selection ranges that span the given row

Arguments

rowCoord?
RowCoorddefault nullRow Coordinate
Returnsarray<SelectionRange>List of selection ranges
getSelectedColRanges(): array<ColRange>

All column ranges in current selection

Returnsarray<ColRange>
getSelectedRowRanges(): array<RowRange>

All row ranges in current selection

Returnsarray<RowRange>
getSelection(): array<SelectionRange>

The current selection

Returnsarray<SelectionRange>List of selection ranges
getState(): object

The current state of the cell selector

Returnsobject{ selection, cellCursorPosition, activeRangeIndex }
isCellSelected(cellCoords): boolean

Check if a particular cell is selected

Arguments

cellCoords
CellCoords
Returnsboolean
isColSelected(colCoord): boolean

Check if a particular column is selected

Arguments

colCoord
ColCoord
Returnsboolean
isRowSelected(rowCoord): boolean

Check if a particular row is selected

Arguments

rowCoord
RowCoord
Returnsboolean
isSet(): boolean

Check if cell selector is set

Returnsboolean
modifyActiveSelectionRange(direction)

Modify (expand or shrink) active selection range in given direction

Arguments

direction
stringup, right, bottom, left
Fires$change
moveCellCursor(mutationCoords)

Move cell cursor by `{x,y}` mutation

Arguments

mutationCoords
CellCoords
moveCellCursorAroundSelection(mutationCoords)

Move cell cursor by `{x,y}` mutation

Arguments

mutationCoords
CellCoords
moveCellCursorToColEnd()

Move cell cursor to the last cell of the current column

moveCellCursorToColStart()

Move cell cursor to the first cell of the current column

moveCellCursorToRowEnd()

Move cell cursor to the last cell of the current row

moveCellCursorToRowStart()

Move cell cursor to the first cell of the current row

moveCellCursorToSheetEnd()

Moves cell cursor to the last cell of the sheet

moveCellCursorToSheetStart()

Moves cell cursor to the first cell of the sheet

selectAll(cellCursorPosition?)

Select all cells in the sheet

Arguments

cellCursorPosition?
CellCoordscellCursorPosition
selectCol(colCoord, cellCursorRowCoord?)

Select a single column

Arguments

colCoord
ColCoordCoordinate of column to select
cellCursorRowCoord?
RowCoorddefault 0Row coordinate of cell cursor
Fires$change
selectRow(rowCoord, cellCursorColCoord?)

Select a single row

Arguments

rowCoord
RowCoordCoordinate of row to select
cellCursorColCoord?
ColCoordColumn coordinate of cell cursor
Fires$change
setCellCursorPosition(cellCoords)

Set cell cursor position at specific coordinates

Arguments

cellCoords
CellCoordsCell Coordinates
setCellRangeExtreme(cellCoords, keepMultiSelection?)

Set extreme of cell range to given cell coordinates

Arguments

cellCoords
CellCoords
keepMultiSelection?
booleandefault falseKeep or clear multi selection
Fires$change
setColRangeExtreme(colCoord, keepMultiSelection?)

Set extreme of column range to given column coordinate

Arguments

colCoord
ColCoord
keepMultiSelection?
booleandefault falseKeep or clear multi selection
Fires$change
setRowRangeExtreme(rowCoord, keepMultiSelection?)

Set extreme of row range to given row coordinate

Arguments

rowCoord
RowCoord
keepMultiSelection?
booleandefault falseKeep or clear multi selection
Fires$change
setState(state)

Set state with { selection, cellCursorPosition, activeRangeIndex }

Arguments

state
object
Fires$change

Events

beforechangeCellSelectorChangeEvent

Payload

type
string
Always `"beforechange"` or `"change"`
target
CellSelector
Instance that fired the event
payload
CellSelectorChangeEventPayload
Structured event data
changeCellSelectorChangeEvent

Payload

type
string
Always `"beforechange"` or `"change"`
target
CellSelector
Instance that fired the event
payload
CellSelectorChangeEventPayload
Structured event data