reactjs - 如何将 selectAll 和 deSelectAll 应用于 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 的标题复选框不起作用。我为 selectAll 和 deselectAll 添加了两个回调,但我不确定在哪里添加这些回调,以便我可以选择和取消选择所有行:
const deselectAllHandler = useCallback(() => {
gridApi.deselectAll();
}, [gridApi]);
const selectAllHandler = useCallback(() => {
gridApi.selectAll();
}, [gridApi]);
我可以选择单个复选框并检索选定的行,但无法全选和取消全选
提前致谢!
解决方案
抱歉,我一直在使用的 Grid 组件是一个共享组件,有人在该复选框上禁用了鼠标单击。因此,此属性 headerCheckboxSelection: true 足以允许全选和取消全选。
推荐阅读
- google-chrome - 使用 Tomcat 时,是否可以自动重新加载客户端文件(js、css、html)而无需在 Google Chrome 中手动刷新页面?
- python - 如何在 Python 中指定函数的输入类型?
- python - 将嵌套字典转换为 json
- flutter - 未处理的异常:“String”类型不是“Uri”类型的子类型
- python - 来自 url 的 Pandas read_csv 返回更少的行数
- .htaccess - 如何通过将显示语言添加为子文件夹在 htaccess 中创建多语言 url
- php - 在 laravel 中找不到类文件?
- flutter - 订阅状态没有从一个屏幕传递到另一个“inAppPurchase”
- android - Android:从片段更新活动中底部导航视图的徽章计数
- android - 如何在我的 recyclerview 中使用 cardview 设置 onclick 侦听器,并在我单击 recyclerview 时从 firebase 数据库中检索数据?