JavaScript 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 codecellCoords.col : number
A visual column index.
row
Source codecellCoords.row : number
A visual row index.
Methods
assign
Source codecellCoords.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 codecellCoords.clone() ⇒ CellCoords
Clones your CellCoords
instance.
isCell
Source codecellCoords.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 codecellCoords.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 codecellCoords.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 codecellCoords.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 codecellCoords.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 codecellCoords.isRtl() ⇒ boolean
Checks if the coordinates runs in RTL mode.
isSouthEastOf
Source codecellCoords.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 codecellCoords.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 codecellCoords.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 codecellCoords.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 codecellCoords.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.