Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ag-Grid : How to get the focused cell value

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

like image 330
Mallikarjuna Avatar asked Jul 17 '18 15:07

Mallikarjuna


People also ask

How to modify the selected row and cell styles in AG-grid?

In order to modify the style of the selected rows and cell range we wrap ag-Grid in a div with a class name that will be used to target the ag-Grid row and cell styles. This way we can target different CSS rules based on the wrapping div's class name.

What are the different parts of the grid concerned with cell values?

The different parts of the grid concerned with cell values are as follows: Value Getter: Instead of specifying colDef.field, you can use colDef.valueGetter to provide a function for getting cell values. This is more flexible than providing field values for specific cells. Value Formatters: Use formatters to format values.

How do I get cell values from the grid in Excel?

There are different aspects of the grid that assist this. The different parts of the grid concerned with cell values are as follows: Value Getter: Instead of specifying colDef.field, you can use colDef.valueGetter to provide a function for getting cell values. This is more flexible than providing field values for specific cells.

How to get the focused cell value at the time?

How to get the focused cell value at the time focussing on the cell by using the keyboard arrow keys or use the onCellFocused event. After that you can use those properties to retrieve the raw value of the cell:


1 Answers

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)
like image 125
Alexander Zbinden Avatar answered Oct 08 '22 13:10

Alexander Zbinden