Class: Selection

Selection

Members

highlightHighlight

Visualization layer.

inProgressBoolean

The flag which determines if the selection is in progress.

selectedByColumnHeaderSet.<Number>

The collection of the selection layer levels where the whole column was selected using the column header.

selectedByCornerBoolean

The flag indicates that selection was performed by clicking the corner overlay.

selectedByRowHeaderSet.<Number>

The collection of the selection layer levels where the whole row was selected using the row header.

selectedRangeSelectionRange

Selection data layer.

settingsGridSettings

Handsontable settings instance.

tablePropsObject

An additional object with dynamically defined properties which describes table state.

transformationTransformation

The module for modifying coordinates.

Methods

begin()

Indicate that selection process began. It sets internaly .inProgress property to true.

clear()

Clear the selection by resetting the collected ranges and highlights.

deselect()

Deselects all selected cells.

finish()

Indicate that selection process finished. It sets internaly .inProgress property to false.

getLayerLevel(){Number}

Returns currently used layer level.

Returns: {Number} Returns layer level starting from 0. If no selection was added to the table -1 is returned.

getSelectedRange(){SelectionRange}

Get data layer for current selection.

Returns: {SelectionRange}

inInSelection(coords){Boolean}

Returns true if coords is within selection coords. This method iterates through all selection layers to check if
the coords object is within selection range.

Parameters:
Name Type Description
coords CellCoords

The CellCoords instance with defined visual coordinates.

Returns: {Boolean}

isAreaCornerVisible(layerLevel){Boolean}

Returns true if the area corner should be visible.

Parameters:
Name Type Description
layerLevel Number

The layer level.

Returns: {Boolean} true if the corner element has to be visible, false otherwise.

isInProgress(){Boolean}

Check if the process of selecting the cell/cells is in progress.

Returns: {Boolean}

isMultiple(){Boolean}

Returns information if we have a multiselection. This method check multiselection only on the latest layer of
the selection.

Returns: {Boolean}

isSelected(){Boolean}

Returns true if currently there is a selection on the screen, false otherwise.

Returns: {Boolean}

isSelectedByAnyHeader(){Boolean}

Returns true if the selection was applied by clicking on the row or column header on any layer level.

Returns: {Boolean}

isSelectedByColumnHeader(layerLevel){Boolean}

Returns true if the selection was applied by clicking to the column header. If the layerLevel
argument is passed then only that layer will be checked. Otherwise, it checks if any column header
was clicked on any selection layer level.

Parameters:
Name Type Default Description
layerLevel Number this.getLayerLevel() optional

Selection layer level to check.

Returns: {Boolean}

isSelectedByCorner(){Boolean}

Returns true if the selection was applied by clicking on the left-top corner overlay.

Returns: {Boolean}

isSelectedByRowHeader(layerLevel){Boolean}

Returns true if the selection was applied by clicking to the row header. If the layerLevel
argument is passed then only that layer will be checked. Otherwise, it checks if any row header
was clicked on any selection layer level.

Parameters:
Name Type Default Description
layerLevel Number this.getLayerLevel() optional

Selection layer level to check.

Returns: {Boolean}

selectAll()

Select all cells.

selectCells(selectionRanges){Boolean}

Make multiple, non-contiguous selection specified by row and column values or a range of cells
finishing at endRow, endColumn. The method supports two input formats, first as an array of arrays such
as [[rowStart, columnStart, rowEnd, columnEnd]] and second format as an array of CellRange objects.
If the passed ranges have another format the exception will be thrown.

Parameters:
Name Type Description
selectionRanges Array.<Array> | Array.<CellRange>

The coordinates which define what the cells should be selected.

Returns: {Boolean} Returns true if selection was successful, false otherwise.

selectColumns(startColumn, endColumn){Boolean}

Select column specified by startColumn visual index or column property or a range of columns finishing at endColumn.

Parameters:
Name Type Description
startColumn Number | String

Visual column index or column property from which the selection starts.

endColumn Number | String optional

Visual column index or column property from to the selection finishes.

Returns: {Boolean} Returns true if selection was successful, false otherwise.

selectRows(startRow, endRow){Boolean}

Select row specified by startRow visual index or a range of rows finishing at endRow.

Parameters:
Name Type Description
startRow Number

Visual row index from which the selection starts.

endRow Number optional

Visual row index from to the selection finishes.

Returns: {Boolean} Returns true if selection was successful, false otherwise.

setRangeEnd(coords)

Ends selection range on given coordinate object.

Parameters:
Name Type Description
coords CellCoords

Visual coords.

setRangeStart(coords, multipleSelection, fragment)

Starts selection range on given coordinate object.

Parameters:
Name Type Default Description
coords CellCoords

Visual coords.

multipleSelection Boolean optional

If true, selection will be worked in 'multiple' mode. This option works
only when 'selectionMode' is set as 'multiple'. If the argument is not defined
the default trigger will be used (isPressedCtrlKey() helper).

fragment Boolean false optional

If true, the selection will be treated as a partial selection where the
setRangeEnd method won't be called on every setRangeStart call.

setRangeStartOnly(coords, multipleSelection)

Starts selection range on given coordinate object.

Parameters:
Name Type Description
coords CellCoords

Visual coords.

multipleSelection Boolean optional

If true, selection will be worked in 'multiple' mode. This option works
only when 'selectionMode' is set as 'multiple'. If the argument is not defined
the default trigger will be used (isPressedCtrlKey() helper).

transformEnd(rowDelta, colDelta)

Sets selection end cell relative to the current selection end cell (if possible).

Parameters:
Name Type Description
rowDelta Number

Rows number to move, value can be passed as negative number.

colDelta Number

Columns number to move, value can be passed as negative number.

transformStart(rowDelta, colDelta, force)

Selects cell relative to the current cell (if possible).

Parameters:
Name Type Description
rowDelta Number

Rows number to move, value can be passed as negative number.

colDelta Number

Columns number to move, value can be passed as negative number.

force Boolean

If true the new rows/columns will be created if necessary. Otherwise, row/column will
be created according to minSpareRows/minSpareCols settings of Handsontable.