Ag Grid单元格渲染器

时间:2020-06-04 13:15:09

标签: angular grid

我在不同的屏幕上使用了单晶Ag Grid Cell Renderer。现在我想在屏幕之一上基于条件为单元格渲染器值添加不同的样式。在这种情况下如何动态应用样式?

1 个答案:

答案 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