React Data GridCellCoords

Description

The CellCoords class holds the coordinates (row, col) of a single cell.

It also contains methods for validating the coordinates and retrieving them as an object.

To import the CellCoords class:

import Handsontable, { CellCoords } from '/handsontable';

// or, using modules
import Handsontable, { CellCoords } from '/handsontable/base';

Members

col

Source code

cellCoords.col : number

A visual column index.

row

Source code

cellCoords.row : number

A visual row index.

Methods

assign

Source code

cellCoords.assign(coords) ⇒ CellCoords

Assigns the coordinates from another CellCoords instance (or compatible literal object) to your CellCoords instance.

Param Type Description
coords CellCoords
Object
The CellCoords instance or compatible literal object.

clone

Source code

cellCoords.clone() ⇒ CellCoords

Clones your CellCoords instance.

isCell

Source code

cellCoords.isCell() ⇒ boolean

Checks if the coordinates point to the cells range. If all axis (row and col) point to the cell (positive value) then method returns true.

isEqual

Source code

cellCoords.isEqual(coords) ⇒ boolean

Checks if another set of coordinates (coords) is equal to the coordinates in your CellCoords instance.

Param Type Description
coords CellCoords Coordinates to check.

isHeader

Source code

cellCoords.isHeader() ⇒ boolean

Checks if the coordinates point to the headers range. If one of the axis (row or col) point to the header (negative value) then method returns true.

isNorthEastOf

Source code

cellCoords.isNorthEastOf(testedCoords) ⇒ boolean

Checks if another set of coordinates (testedCoords) is north-east of the coordinates in your CellCoords instance.

Param Type Description
testedCoords CellCoords Coordinates to check.

isNorthWestOf

Source code

cellCoords.isNorthWestOf(testedCoords) ⇒ boolean

Checks if another set of coordinates (testedCoords) is north-west of the coordinates in your CellCoords instance.

Param Type Description
testedCoords CellCoords Coordinates to check.

isRtl

Source code

cellCoords.isRtl() ⇒ boolean

Checks if the coordinates runs in RTL mode.

isSouthEastOf

Source code

cellCoords.isSouthEastOf(testedCoords) ⇒ boolean

Checks if another set of coordinates (testedCoords) is south-east of the coordinates in your CellCoords instance.

Param Type Description
testedCoords CellCoords Coordinates to check.

isSouthWestOf

Source code

cellCoords.isSouthWestOf(testedCoords) ⇒ boolean

Checks if another set of coordinates (testedCoords) is south-west of the coordinates in your CellCoords instance.

Param Type Description
testedCoords CellCoords Coordinates to check.

isValid

Source code

cellCoords.isValid([tableParams]) ⇒ boolean

Checks if the coordinates in your CellCoords instance are valid in the context of given table parameters.

The row index:

  • Must be an integer.
  • Must be higher than the number of column headers in the table.
  • Must be lower than the total number of rows in the table.

The col index:

  • Must be an integer.
  • Must be higher than the number of row headers in the table.
  • Must be lower than the total number of columns in the table.
Param Type Default Description
[tableParams] object optional An object with a defined table size.
[tableParams.countRows] number 0 optional The total number of rows.
[tableParams.countCols] number 0 optional The total number of columns.
[tableParams.countRowHeaders] number 0 optional A number of row headers.
[tableParams.countColHeaders] number 0 optional A number of column headers.

Returns: boolean - true: The coordinates are valid.

normalize

Source code

cellCoords.normalize() ⇒ CellCoords

Normalizes the coordinates in your CellCoords instance to the nearest valid position.

Coordinates that point to headers (negative values) are normalized to 0.

toObject

Source code

cellCoords.toObject() ⇒ Object

Converts your CellCoords instance into an object literal with row and col properties.

Returns: Object - An object literal with row and col properties.