简体   繁体   English

如何在 AG-Grid 中禁用 SELECT OPTION

[英]How to disable a SELECT OPTION in AG-Grid

I'm trying to disable a dropdown element in AG-Grid and React.我正在尝试禁用 AG-Grid 和 React 中的下拉元素。 Like this example from W3Schools:就像 W3Schools 的这个例子:

option value="volvo" disabled>Volvo选项值=“沃尔沃”禁用>沃尔沃

This will be a dynamically built dropdown and I can find no mention of the ability to do this using a cellEditor or cellEditorParams.这将是一个动态构建的下拉列表,我找不到使用 cellEditor 或 cellEditorParams 执行此操作的能力。 I can find no evidence that disabling a dropdown option is possible in AG-Grid.我找不到任何证据表明在 AG-Grid 中可以禁用下拉选项。

You can achieve this by using a custom cell renderer for that field ie您可以通过为该字段使用自定义单元格渲染器来实现此目的,即

 {
     field: 'yourField',
     cellRenderer: 'selectboxRenderer',

    // Here **disable** is the prop that will get passed to your selectBoxRenderer
    // You can put your condition when based on which you want to disable
    // You will also have to receive that **prop** in your component
      cellRendererParams: {
          disable: ({ data }) => { 
              // Your condition here
          },
      }
 }

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

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