【发布时间】:2022-01-19 17:48:40
【问题描述】:
是否可以在ag-grid的columnDefs中实现条件字段?每当 rowData 中有“anotherValue”时,我希望为 columnDefs 中的字段值呈现“anotherField”。
例如我有数据:
this.gridOptions.rowData = [
{ id: 5, value: 10 },
{ id: 10, value: 15 },
{ id: 15, value: 20, anotherValue: 500 },
];
及列定义:
this.gridOptions.columnDefs = [
{
headerName: 'ID',
field: 'id',
width: 100,
},
{
headerName: 'Value',
field: 'anotherValue' ? 'anotherValue' : 'value', //this part doesn't work
cellRendererFramework: RedComponentComponent,
width: 100,
},
];
请参阅 stackblitz 示例。任何建议都非常感谢。
【问题讨论】:
标签: angular ag-grid ag-grid-angular