You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AG Grid React列选择模态框:禁用全选及指定列选控

AG Grid React 列选择模态框自定义实现方案

1. 禁用全选/取消全选复选框

直接在Grid配置项gridOptions中添加suppressColumnSelectAll: true,即可隐藏并禁用列选择模态框顶部的全选复选框:

const gridOptions = {
  // 其他Grid配置...
  suppressColumnSelectAll: true,
};

<AgGridReact
  gridOptions={gridOptions}
  // 其他组件props...
/>

2. 禁用指定列的选/取消选功能

针对需要锁定可见性的列,在其列定义colDef中设置lockVisible: true,该列的复选框会变为禁用状态,用户无法修改其可见性:

const columnDefs = [
  { field: 'id', headerName: 'ID', lockVisible: true }, // 禁用该列的选/取消选操作
  { field: 'name', headerName: '名称' },
  { field: 'age', headerName: '年龄', lockVisible: true }, // 另一列禁用操作
];

<AgGridReact
  columnDefs={columnDefs}
  // 其他组件props...
/>

如果需要让列直接从模态框中消失(而非保留选项但禁用),可以改用suppressColumnsToolPanel: true,但此配置会直接移除该列的选项,而非仅禁用操作。

内容的提问来源于stack exchange,提问作者Spandan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 12:07:04