首页 > 解决方案 > 在刷新视图/刷新单元格后设置焦点在 ag 网格角度 2 中不起作用

问题描述

我有一个单元格渲染器,它是一个文本框。

 <input type="text"[(ngModel)]="textVal" class="form-control mb-2 mr-sm-2 mb-sm-0"
id="measurename" (input)="onValChange()">

每当我在文本框中写东西时,我都会根据一些逻辑更新其他行中的数据

for (const node of this.selectedRowNodes) {
  if (this.parameterDefMap[this.parameterDefName]) {
    node.data.parameters[this.gridParams.colDef.field] = this.textVal;
  }
}

之后我尝试刷新单元格/视图以更新网格中的数据

const cell: GridCell = this.gridParams.api.getFocusedCell();
this.gridParams.api.refreshCells(params);


if (cell) {
  this.gridParams.api.setFocusedCell(cell.rowIndex, cell.column);
  const col = cell.column.getColDef().field;
}

网格已成功刷新,但我的问题是刷新焦点丢失后,当我尝试将焦点设置到具有文本字段的单元格时,焦点未设置。

标签: ag-grid-ng2

解决方案


推荐阅读