Skip to content

@jsvision/datagrid / prevCellIndex

Function: prevCellIndex() ​

prevCellIndex(col, row, cols, rows): CellMove

Defined in: datagrid/src/navigation.ts:61

The cell one step backward from (col, row) — the mirror of nextCellIndex. Before the first column it wraps to the last column of the previous row; at (0, 0) (and for an empty grid) it returns 'exit'.

Parameters ​

col ​

number

The current column index.

row ​

number

The current row index.

cols ​

number

The visible column count.

rows ​

number

The display row count.

Returns ​

CellMove

The previous cell, or 'exit' at the grid's start.

Example ​

ts
import { prevCellIndex } from '@jsvision/datagrid';
prevCellIndex(2, 1, 3, 3); // { col: 1, row: 1 }
prevCellIndex(0, 1, 3, 3); // { col: 2, row: 0 } — wraps
prevCellIndex(0, 0, 3, 3); // 'exit'