繁体   English   中英

如何将 selectAll 和 deSelectAll 应用于 ag-grid react 中的 header 复选框

[英]how to apply selectAll and deSelectAll to the header checkbox in ag-grid react

我已将 checkboxSelection 添加到我的第一列以及 headerCheckBoxSelection。

columnDefs: [
  {
    minWidth: 45,
    maxWidth: 45,
    headerCheckboxSelection: true,
    checkboxSelection: true,
    lockPosition: true,
    hide: selectedHeaders.length === 0 ? true : selectedHeaders.includes('Name')
  },

但是 select 和 deseltall 的 header 复选框不起作用。 我为 selectAll 和 deselectAll 添加了两个回调,但我不确定在哪里添加这些回调,以便我可以 select 并取消选择所有行:

const deselectAllHandler = useCallback(() => {
 gridApi.deselectAll();
}, [gridApi]);

const selectAllHandler = useCallback(() => {
 gridApi.selectAll();
}, [gridApi]);

我能够 select 单个复选框并检索选定的行,但无法 select 全部并取消选择所有

在此处输入图像描述

提前致谢!

抱歉,我一直在使用的 Grid 组件是一个共享组件,有人在该复选框上禁用了鼠标单击。 因此,此属性 headerCheckboxSelection: true 足以允许 select 并取消全选。

暂无
暂无

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

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