Ag-grid与cell相反的方法 [英] Ag-grid opposite method to cellFocused

查看:144
本文介绍了Ag-grid与cell相反的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

民间!
有人知道ag-grid中 cellFocused 的相反方法吗?
我需要检测焦点单元何时失去焦点并执行一些操作。

folks! Does anyone know the opposite method to cellFocused in ag-grid? I need to detect when the focused cell loses its focus and run some actions.

感谢您的回复。

推荐答案

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

I've found a way to support onBlur event. 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.

所以,我的代码如下所示。在react类内部,我有3种其他方法:

So, my code looks like this. Inside the react class I have 3 additional methods:

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}
         />
    );
}

这篇关于Ag-grid与cell相反的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆