我在不同的屏幕上使用了Singe Ag Grid Cell Renderer,现在我想在其中一个屏幕上根据条件为单元格渲染值添加不同的样式。现在我想在其中一个屏幕上根据条件为单元格渲染器的值添加不同的样式。在这种情况下,如何动态地应用样式?
试试这个。
columns= [
{
headerName: 'Employee'
field : 'emp'
colId : 'emp'
},
{
headerName: 'Role'
field : 'role'
colId : 'role'
}
]
在单元格渲染器组件中
export class CellRendererComponent implements ICellRendererAngularComp {
public params: any;
constructor() {}
agInit(params) {
this.params = params;
}
}
在HTML文件中
<div>
<span class="customClass" *ngIf="params.colDef.colId === 'emp'">{{params.data}}</span>
<span class="customClassforRole" *ngIf="params.colDef.colId === 'role'">{{params.data}}</span>
</div>
供参考 : 链接