简体   繁体   English

Ag Grid 单元格渲染器

[英]Ag Grid Cell Renderer

I am using singe Ag Grid Cell Renderer, in different screens.我在不同的屏幕上使用单一的 Ag Grid Cell Renderer。 Now i want to add different styles on on one of the screen for cell renderer value based on condition.现在我想根据条件在其中一个屏幕上添加不同的 styles 以获取单元格渲染器值。 How to apply styles dynamically in such case?在这种情况下如何动态应用 styles?

try this:尝试这个:

columns= [
{

 headerName: 'Employee'
 field : 'emp'
 colId : 'emp'

},
{

 headerName: 'Role'
 field : 'role'
 colId : 'role'

}
]

in Cell Renderer Component在单元格渲染器组件中

export class CellRendererComponent implements ICellRendererAngularComp {
  public params: any;

  constructor() {}

  agInit(params) {

   this.params = params;

  }

}

in HTML file在 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>

For Reference: link供参考: 链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM