Skip to main content

useActiveCell

Get the coordinates of cell where the cursor is currently active, return a ICell. Rerendering is triggered, When the cursor is moved or the view is switched.

If you need to information not only about the activated cell, but also the selection, please use useSelection.

Returns

ICell | undefined

Example

import { useActiveCell, useRecord } from '@apitable/widget-sdk';

// Render the value of currently selected cell
function ActiveCell() {
const activeCell = useActiveCell();
const activeRecord = useRecord(activeCell?.recordId);
if (!activeCell || !activeRecord) {
return <p>Cells without activation</p>
}
return <p>Activated Cells: {activeRecord.getCellValueString(activeCell.fieldId)}</p>
}