Ag-grid : 单元格编辑器 Aginit 被调用两次

Ag-grid : Cell Editors Aginit get called twice

框架:Angular6+ 和 Ag Grid Api

我有 CellEditorcomponent 实现 AgEditorComponent 并且在按键时,我开始使用 agApi.startEditingCells(params) 进行编辑,并为 CellEditorComponent

执行 Aginit()

CellEditingStartedEvent 正在侦听并进行服务器调用,并根据响应允许编辑。为了确保用户不会将焦点从单元格中移出,我有 re-called 那个 agApi.startEditingCells(params) 对于相同的 "Column and rowIndex with charpress, keyPress" 但 CellEditorComponent 被销毁并再次 re-created 。 我有以下内容: 1) 如何防止 agGridApi.StartEditingCell() 调用 CellEditor 的 AgInit() 两次。 2) 从相同的列和行索引调用 StartEditingCell() 将 re-created cellEditorcomponent?

如果我没理解错的话,您是从 CellEditorComponent 调用 startEditingCells。 您不应该这样做,因为如果您的 CellEditorComponent 处于活动状态,那么您已经在进行编辑。调用 startEditingCells 可能会导致网格破坏您的 CellEditorComponent 并创建一个新的,因此多次调用 agInit

startEditingCells 用于从网格外部(通常来自网格的父组件)手动触发编辑。