Material UI Data Grid隐藏id列后,如何移除过滤器中的id选项
解决Material UI Data Grid隐藏列仍出现在过滤器中的问题
要让隐藏的id字段同时从过滤器选项中消失,只需在该列的定义里添加filterable: false属性即可——默认情况下所有列都是可过滤的,hide: true仅控制列的显示,不会影响过滤器的选项列表。
修改后的列配置代码如下:
const userColumns = [ { field: "id", hide: true, filterable: false }, // 添加filterable: false { field: "name", headerName: "Name", flex: 1 }, { field: "email", headerName: "Email", flex: 1 }, { field: "group", headerName: "Group", flex: 1 }, { field: "supplier", headerName: "Supplier", flex: 1 } ];
这样设置后,id字段既不会在表格中显示,也不会出现在过滤器的可选字段列表里。
内容的提问来源于stack exchange,提问作者Joseph
相关产品推荐
相关产品推荐

