我在不同的屏幕上使用了单晶Ag Grid Cell Renderer。现在我想在屏幕之一上基于条件为单元格渲染器值添加不同的样式。在这种情况下如何动态应用样式?
答案 0 :(得分:0)
尝试一下:
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>
供参考:link