angular - 我在 Angular 6 中使用 ag-grid。我已经实现了自定义全选功能。但是全选不能随着过滤器的变化而正常工作
问题描述
我想在过滤器更改时重新计算正确的选定行。
//服务器端全选
selectAllRows(e) {
const firstRow = this.gridApi.getFirstDisplayedRow();
const lastRow = this.gridApi.getLastDisplayedRow();
if(e.checked) {
for (let idx = firstRow; idx <= lastRow; idx++) {
this.gridApi.getDisplayedRowAtIndex(idx).setSelected(true);
// this.gridApi.selectIndex(idx, true);
}
// this.gridApi.selectionController.selectAllRowNodes(true);
} else {
this.gridOptions.api.deselectAll();
}
}
解决方案
用于api.selectAllFiltered()
选择网格中的所有过滤行。
在此处查看文档 - https://www.ag-grid.com/javascript-grid-selection/#grid-selection-api
推荐阅读
- xml - 有没有办法“简化” VSCode 调试器,使其更像 Chrome 的?
- php - 如何制作自定义 PSR-7 ResponseInterface 以减少样板文件?
- postgresql - pgadmin 远程访问 kubernetes 中的 postresql 服务
- wordpress - 重写 URL 子目录
- r - 在 3D 空间中绘制立方体
- d3.js - 基于时间的 C3 StackedBar 图表,x 轴为小时
- mysql - 加载数据 infile 什么都不做
- python - 如何“重置”在使用来自 Flask 应用程序的数据库的 Python 脚本中运行的 db.session?
- reactjs - 类型“IntrinsicAttributes”上不存在属性“历史”
- javascript - React 页面加载时的 Swiper React 断点(引导程序)