React Data GridCellRange
- Description
- Methods
- clone
- containsHeaders
- expand
- expandByRange
- flipDirectionHorizontally
- flipDirectionVertically
- forAll
- getAll
- getBordersSharedWith
- getBottomEndCorner
- getBottomLeftCorner
- getBottomRightCorner
- getBottomStartCorner
- getCellsCount
- getDirection
- getHeight
- getHorizontalDirection
- getInner
- getOppositeCorner
- getOuterBottomEndCorner
- getOuterBottomLeftCorner
- getOuterBottomRightCorner
- getOuterBottomStartCorner
- getOuterHeight
- getOuterTopEndCorner
- getOuterTopLeftCorner
- getOuterTopRightCorner
- getOuterTopStartCorner
- getOuterWidth
- getTopEndCorner
- getTopLeftCorner
- getTopRightCorner
- getTopStartCorner
- getVerticalDirection
- getWidth
- includes
- includesRange
- isCorner
- isEqual
- isHeader
- isNorthWestOf
- isOverlappingHorizontally
- isOverlappingVertically
- isSingle
- isSingleCell
- isSingleHeader
- isSouthEastOf
- isValid
- overlaps
- setDirection
- setFrom
- setHighlight
- setTo
- toObject
Description
The CellRange
class holds a set of cell coordinates (CellCoords
instances)
that form a selection range.
A single CellRange
instance represents a single unit of selection
that contains either a single cell or multiple adjacent cells.
To import the CellRange
class:
import Handsontable, { CellRange } from '/handsontable';
// or, using modules
import Handsontable, { CellRange } from '/handsontable/base';
Methods
clone
Source codecellRange.clone() ⇒ CellRange
Clones your CellRange
instance.
containsHeaders
Source codecellRange.containsHeaders() ⇒ boolean
Checks if your range overlaps headers range (negative coordinates).
expand
Source codecellRange.expand(cellCoords) ⇒ boolean
Adds a cell to your range, at cellCoords
coordinates.
The cellCoords
coordinates must exceed a corner of your range.
Param | Type | Description |
---|---|---|
cellCoords | CellCoords | A new cell's coordinates. |
expandByRange
Source codecellRange.expandByRange(expandingRange, [changeDirection]) ⇒ boolean
Expand your range with another range (expandingRange
).
Param | Type | Default | Description |
---|---|---|---|
expandingRange | CellRange | A new range. | |
[changeDirection] | boolean | true | optional If true , the direction of your range is changed to the direction of the expandingRange range. |
flipDirectionHorizontally
Source codecellRange.flipDirectionHorizontally()
Flips the direction of your range horizontally (e.g., NW-SE
changes to NE-SW
).
flipDirectionVertically
Source codecellRange.flipDirectionVertically()
Flips the direction of your range vertically (e.g., NW-SE
changes to SW-NE
).
forAll
Source codecellRange.forAll(callback)
Runs a callback function on all cells within your range.
You can break the iteration by returning false
in the callback function.
Param | Type | Description |
---|---|---|
callback | function | A callback function. |
getAll
Source codecellRange.getAll() ⇒ Array<CellCoords>
Gets the coordinates of all cells of your range.
getBordersSharedWith
Source codecellRange.getBordersSharedWith(range) ⇒ Array<('top'|'right'|'bottom'|'left')>
Indicates which borders (top, right, bottom, left) are shared between
your CellRange
instance and another range
that's within your range.
Param | Type | Description |
---|---|---|
range | CellRange | A range to compare with. |
getBottomEndCorner
Source codecellRange.getBottomEndCorner() ⇒ CellCoords
Gets the bottom right (in LTR) or bottom left (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getBottomLeftCorner
Source codecellRange.getBottomLeftCorner() ⇒ CellCoords
Gets the bottom left corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getBottomRightCorner
Source codecellRange.getBottomRightCorner() ⇒ CellCoords
Gets the bottom right corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getBottomStartCorner
Source codecellRange.getBottomStartCorner() ⇒ CellCoords
Gets the bottom left (in LTR) or bottom right (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getCellsCount
Source codecellRange.getCellsCount() ⇒ number
Returns the number of cells within your range (excluding column and row headers).
getDirection
Source codecellRange.getDirection() ⇒ string
Gets the direction of the selection.
Returns: string
- Returns one of the values: 'NW-SE'
, 'NE-SW'
, 'SE-NW'
, 'SW-NE'
.
getHeight
Source codecellRange.getHeight() ⇒ number
Returns the height of your range (as a number of rows, excluding row headers).
getHorizontalDirection
Source codecellRange.getHorizontalDirection() ⇒ string
Gets the horizontal direction of the selection.
Returns: string
- Returns one of the values: W-E
(west->east), E-W
(east->west).
getInner
Source codecellRange.getInner() ⇒ Array<CellCoords>
Gets the coordinates of the inner cells of your range.
getOppositeCorner
Source codecellRange.getOppositeCorner(coords) ⇒ CellCoords
Gets the coordinates of a range corner opposite to the provided coords
.
For example: if the coords
coordinates match the bottom-right corner of your range,
the coordinates of the top-left corner of your range are returned.
Param | Type | Description |
---|---|---|
coords | CellCoords | Coordinates to check. |
getOuterBottomEndCorner
Source codecellRange.getOuterBottomEndCorner() ⇒ CellCoords
Gets the bottom right (in LTR) or bottom left (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values), the top and start coordinates are pointed to that header.
getOuterBottomLeftCorner
Source codecellRange.getOuterBottomLeftCorner() ⇒ CellCoords
Gets the bottom left corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values), the top and left coordinates are pointed to that header.
getOuterBottomRightCorner
Source codecellRange.getOuterBottomRightCorner() ⇒ CellCoords
Gets the bottom right corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values), the top and left coordinates are pointed to that header.
getOuterBottomStartCorner
Source codecellRange.getOuterBottomStartCorner() ⇒ CellCoords
Gets the bottom left (in LTR) or bottom right (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values), the top and start coordinates are pointed to that header.
getOuterHeight
Source codecellRange.getOuterHeight() ⇒ number
Returns the height of your range (as a number of rows, including row headers).
getOuterTopEndCorner
Source codecellRange.getOuterTopEndCorner() ⇒ CellCoords
Gets the top right (in LTR) or top left (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values), the top and start coordinates are pointed to that header.
getOuterTopLeftCorner
Source codecellRange.getOuterTopLeftCorner() ⇒ CellCoords
Gets the top left corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values), the top and left coordinates are pointed to that header.
getOuterTopRightCorner
Source codecellRange.getOuterTopRightCorner() ⇒ CellCoords
Gets the top right corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values), the top and left coordinates are pointed to that header.
getOuterTopStartCorner
Source codecellRange.getOuterTopStartCorner() ⇒ CellCoords
Gets the top left (in LTR) or top right (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values), the top and start coordinates are pointed to that header.
getOuterWidth
Source codecellRange.getOuterWidth() ⇒ number
Returns the width of your range (as a number of columns, including column headers).
getTopEndCorner
Source codecellRange.getTopEndCorner() ⇒ CellCoords
Gets the top right (in LTR) or top left (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getTopLeftCorner
Source codecellRange.getTopLeftCorner() ⇒ CellCoords
Gets the top-left corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getTopRightCorner
Source codecellRange.getTopRightCorner() ⇒ CellCoords
Gets the top right corner coordinates of your range, both in the LTR and RTL layout direction.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getTopStartCorner
Source codecellRange.getTopStartCorner() ⇒ CellCoords
Gets the top-left (in LTR) or top-right (in RTL) corner coordinates of your range.
If the corner contains header coordinates (negative values),
the corner coordinates are normalized to 0
.
getVerticalDirection
Source codecellRange.getVerticalDirection() ⇒ string
Gets the vertical direction of the selection.
Returns: string
- Returns one of the values: N-S
(north->south), S-N
(south->north).
getWidth
Source codecellRange.getWidth() ⇒ number
Returns the width of your range (as a number of columns, excluding column headers).
includes
Source codecellRange.includes(cellCoords) ⇒ boolean
Checks if another set of coordinates (cellCoords
)
is within the from
and to
coordinates of your range.
Param | Type | Description |
---|---|---|
cellCoords | CellCoords | Coordinates to check. |
includesRange
Source codecellRange.includesRange(cellRange) ⇒ boolean
Checks if another range (cellRange
) is within your range.
Param | Type | Description |
---|---|---|
cellRange | CellRange | A range to check. |
isCorner
Source codecellRange.isCorner(coords) ⇒ boolean
Checks if a set of coordinates (coords
) matches one of the 4 corners of your range.
Param | Type | Description |
---|---|---|
coords | CellCoords | Coordinates to check. |
isEqual
Source codecellRange.isEqual(cellRange) ⇒ boolean
Checks if another range (cellRange
) is equal to your range.
Param | Type | Description |
---|---|---|
cellRange | CellRange | A range to check. |
isHeader
Source codecellRange.isHeader() ⇒ boolean
Checks if your range covers only headers range (negative coordinates, without any cells).
isNorthWestOf
Source codecellRange.isNorthWestOf(cellCoords) ⇒ boolean
Checks if coordinates point is north-west of your range.
Param | Type | Description |
---|---|---|
cellCoords | CellRange | Coordinates to check. |
isOverlappingHorizontally
Source codecellRange.isOverlappingHorizontally(cellRange) ⇒ boolean
Checks if another range (cellRange
) overlaps your range horizontally.
For example: returns true
if the last column of your range is 5
and the first column of the cellRange
range is 3
.
Param | Type | Description |
---|---|---|
cellRange | CellRange | A range to check. |
isOverlappingVertically
Source codecellRange.isOverlappingVertically(cellRange) ⇒ boolean
Checks if another range (cellRange
) overlaps your range vertically.
For example: returns true
if the last row of your range is 5
and the first row of the cellRange
range is 3
.
Param | Type | Description |
---|---|---|
cellRange | CellRange | A range to check. |
isSingle
Source codecellRange.isSingle() ⇒ boolean
Checks if your range is just a single cell or header.
isSingleCell
Source codecellRange.isSingleCell() ⇒ boolean
Checks if your range is just a single cell.
isSingleHeader
Source codecellRange.isSingleHeader() ⇒ boolean
Checks if your range is just a single header.
isSouthEastOf
Source codecellRange.isSouthEastOf(cellCoords) ⇒ boolean
Checks if coordinates point is south-east of your range.
Param | Type | Description |
---|---|---|
cellCoords | CellCoords | Coordinates to check. |
isValid
Source codecellRange.isValid(tableParams) ⇒ boolean
Checks if the coordinates in your CellRange
instance are valid
in the context of given table parameters.
See the isValid()
method of the CellCoords
class.
Param | Type | Description |
---|---|---|
tableParams | object | An object with a defined table size. |
tableParams.countRows | number | The total number of rows. |
tableParams.countCols | number | The total number of columns. |
tableParams.countRowHeaders | number | A number of row headers. |
tableParams.countColHeaders | number | A number of column headers. |
overlaps
Source codecellRange.overlaps(cellRange) ⇒ boolean
Checks if another range (cellRange
) overlaps your range.
Range A overlaps range B if the intersection of A and B (or B and A) is not empty.
Param | Type | Description |
---|---|---|
cellRange | CellRange | A range to check. |
setDirection
Source codecellRange.setDirection(direction)
Sets the direction of the selection.
Param | Type | Description |
---|---|---|
direction | string | One of the values: 'NW-SE' , 'NE-SW' , 'SE-NW' , 'SW-NE' . |
setFrom
Source codecellRange.setFrom(coords) ⇒ CellRange
Sets the coords
coordinates as the start of your range.
Param | Type | Description |
---|---|---|
coords | CellCoords | Coordinates to use. |
setHighlight
Source codecellRange.setHighlight(coords) ⇒ CellRange
Highlights cell selection at the coords
coordinates.
Param | Type | Description |
---|---|---|
coords | CellCoords | Coordinates to use. |
setTo
Source codecellRange.setTo(coords) ⇒ CellRange
Sets the coords
coordinates as the end of your range.
Param | Type | Description |
---|---|---|
coords | CellCoords | Coordinates to use. |
toObject
Source codecellRange.toObject() ⇒ Object
Converts your CellRange
instance into an object literal with the following properties:
from
row
col
to
row
col
Returns: Object
- An object literal with from
and to
properties.