Ag-Grid : How to get the focused cell value

Mallikarjuna picture Mallikarjuna · Jul 17, 2018 · Viewed 10.5k times · Source

How to get the focused cell value at the time focussing on the cell by using the keyboard arrow keys

Answer

Alexander Zbinden picture Alexander Zbinden · Jul 18, 2018

You can either get the focused cell by using

var focusedCell = gridOptions.api.getFocusedCell();

or use the onCellFocused event.

Both give you the following properties:

  • rowIndex: number
  • column: Column

Use the row-index to retrieve the row-node:

var row = gridOptions.api.getDisplayedRowAtIndex(rowIndex);

After that you can use those properties to retrieve the raw value of the cell:

var cellValue = gridOptions.api.getValue(colKey, row.node)