Ag-Grid:如何获得有针对性的细胞价值

Mal*_*una 6 grid ag-grid ag-grid-react

如何通过使用键盘箭头键在聚焦于单元格的时间获得聚焦单元格值

Ale*_*den 16

您可以通过使用获得聚焦单元格

var focusedCell = gridOptions.api.getFocusedCell();
Run Code Online (Sandbox Code Playgroud)

或使用onCellFocused事件.

两者都为您提供以下属性:

  • rowIndex:数字
  • 列:列

使用row-index检索行节点:

var row = gridOptions.api.getDisplayedRowAtIndex(rowIndex);
Run Code Online (Sandbox Code Playgroud)

之后,您可以使用这些属性来检索单元格的原始值:

var cellValue = gridOptions.api.getValue(colKey, row.node)
Run Code Online (Sandbox Code Playgroud)