【问题标题】:How to put css color style on particular row of ag ng2 grid in Angular2 on the value of column?如何将css颜色样式放在Angular2中ag ng2网格的特定行上的列值上?
【发布时间】:2017-05-09 03:24:53
【问题描述】:

当列数据值与我的条件匹配时,我想在行上插入 css 样式

提前致谢

【问题讨论】:

标签: angular typescript


【解决方案1】:

使用 ElementRef 指令如下:

import {Component, ElementRef} from "@angular/core";

constructor(private el: ElementRef) {        
    this.sharedData = sharedResource.SharedComponent;        
} 

SetRowStyle(colValue)
{
    if (colValue == "yourCondition") {
         let tableCol= this.el.nativeElement.closest(".tableTd");
         tableCol.style.padding = 0;
    }
}

注意:我已经在表格列上应用了 css,而且你可以找到它的父级并将 css 应用到行上

【讨论】:

  • 一个[class]绑定属性会更简洁,避免使用ElementRef
猜你喜欢
  • 2017-11-15
  • 2019-07-30
  • 1970-01-01
  • 2017-08-14
  • 1970-01-01
  • 2012-12-23
  • 2016-05-19
  • 2016-03-15
  • 2022-10-20
相关资源
最近更新 更多