Ag-grid 与 cellFocused 相反的方法

Ag-grid opposite method to cellFocused

伙计们! 有谁知道 ag-grid 中 cellFocused 的相反方法? 我需要检测聚焦单元何时失去焦点和 运行 一些动作。

感谢您的回复。

我找到了支持 onBlur 事件的方法。由于 ag-grid 没有内置方法,我为焦点单元格节点创建了自己的事件侦听器,并在失去焦点状态后将其删除。

因此,我的代码如下所示。在反应中 class 我有 3 个额外的方法:

removeCellBlurListener = () => {
    const target = document.activeElement;
    if (target) {
        target.removeEventListener('blur', this.onCellBlur);
    }
};

addCellBlurListener = () => {
    const target = document.activeElement;
    if (target) {
        target.addEventListener('blur', this.onCellBlur);
    }
};

onCellBlur = () => {
    ...do something on blur
};

render () {
    return (
        <AgGridReact
              {...restProps}
              onCellFocused={(e) => this.addCellBlurListener()}
              onGridReady={this.onGridReady}
         />
    );
}