简体   繁体   English

如何禁用 DataGrid MUI 中的菜单按钮选项?

[英]How to disable the menu button option in DataGrid MUI?

I want to disable the button that pops all the options like: Sort, Filter, Hide, Etc.我想禁用弹出所有选项的按钮,如:排序、过滤、隐藏等。

在此处输入图片说明

I know you can remove the sorting option in the columns with sortable: false and if I want to remove everything else then I can simply use Both of this disableColumnFilter to remove the filter and disableColumnSelector to remove pretty much everything else However even if I remove all the options the button is still there and I want to remove it.我知道您可以使用sortable: false删除列中的排序选项,如果我想删除其他所有内容,那么我可以简单地使用这两个disableColumnFilter来删除过滤器并使用disableColumnSelector来删除几乎所有其他内容但是即使我删除所有按钮的选项仍然存在,我想将其删除。

在此处输入图片说明

I should have done more research before asking but I found the answer after checking for something else.我应该在问之前做更多的研究,但我在检查其他东西后找到了答案。

So you have 3 'modifiers'所以你有 3 个“修饰符”

  • disableColumnMenu
  • disableColumnFilter
  • disableColumnSelector

disableColumnMenu will completely remove the button with the options disableColumnFilter will just remove the filter option disableColumnSelector will remove the hide/show columns disableColumnMenu将完全删除带有选项disableColumnFilter的按钮将只删除过滤器选项disableColumnSelector将删除隐藏/显示列

you can check the sort true/false while creating the columns with a simple sortable = true/false您可以在使用简单的sortable = true/false创建列时检查sortable = true/false

Ej: Ej:

const columns = [
        { field: 'name', headerName: 'Name', width: 450, sortable: true/false}
      ]

And this is how it looks with disableColumnMenu it doesn't show the button anymore at all这就是disableColumnMenu样子,它根本不再显示按钮

在此处输入图片说明

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

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