繁体   English   中英

Ag-Grid:如何根据特定行值显示列的不同下拉值

[英]Ag-Grid: How to show different dropdown values for a column based on specific row value

这是我的代码```

   this.columnDefs= [
       {
        headerName: 'Type',
        field: 'type',
        editable: true
       },
       {
        headerName: 'DropdownColumn'
        field: 'ddValue',
        cellEditor:'agRichSelectCellEditor',
        cellEditorParams: function(params) {
        'Need to show different dropdown values based on field type'
        },
        cellRenderer: function(params) {
         'What to do here'
`Need to use prime-ng p-dropdown. Any way to include html in cells`
        }
    ]

例如 - 假设 Grid 有两行

第一行 - 类型 = A,DropdownValue 应该显示

 cellEditorParams : { values: ['A', 'B','C','D'] }
`Need to use prime-ng p-dropdown. Any way to include html in cells`

第二行- Type = S,DropdownValue 应该显示

 cellEditorParams : { values: ['S', 'T','U','V'] }
`Need to use prime-ng p-dropdown. Any way to include html in cells`

如何根据 Ag-Grid 中的特定行值在列中显示不同的下拉值?

编辑值,例如我需要使用具有特定ng-modelclick functions的 Prime-ng 下拉菜单,类似于我们在 html 中所做的。

我想我们使用cellRenderer在 ag-grid 中包含 html

您可以从 param.data 中获取param.data并在检查条件后返回值。

cellEditorParams: (param) => {
          if (param.data.type === "your condition") {
            return {
              values: ["A", "B", "C", "D"]
            };
          }
          else {
            return {
              values: ['S', 'T','U','V']
            }
          }
        }

您可以根据您的要求对其进行更多优化。

暂无
暂无

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

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