Ag Grid Cell Renderer

问题描述 投票:0回答:1

我在不同的屏幕上使用了Singe Ag Grid Cell Renderer,现在我想在其中一个屏幕上根据条件为单元格渲染值添加不同的样式。现在我想在其中一个屏幕上根据条件为单元格渲染器的值添加不同的样式。在这种情况下,如何动态地应用样式?

angular grid ag
1个回答
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>

供参考 : 链接

© www.soinside.com 2019 - 2024. All rights reserved.