简体   繁体   English

与 cellFocused 相对的 Ag-grid 方法

[英]Ag-grid opposite method to cellFocused

folks!伙计们! Does anyone know the opposite method to cellFocused in ag-grid?有谁知道在 ag-grid 中与cellFocused相反的方法? I need to detect when the focused cell loses its focus and run some actions.我需要检测焦点单元何时失去焦点并运行一些操作。

Thanks for your responses.感谢您的回复。

在此处输入图像描述

I've found a way to support onBlur event.我找到了一种支持onBlur事件的方法。 Since ag-grid doesn't have a built-in method, I created wy own event listener to the focus cell node and remove it after losing the focus state.由于 ag-grid 没有内置方法,我为焦点单元节点创建了自己的事件侦听器,并在失去焦点 state 后将其删除。

So, my code looks like this.所以,我的代码看起来像这样。 Inside the react class I have 3 additional methods:在反应 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}
         />
    );
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM