ngx-datatable cellClass作为templateRef中的函数

时间:2018-12-12 05:23:10

标签: angular ngx-datatable

我尝试将我的CSS类实现到ngx-datatable单元 如演示中所示:https://swimlane.github.io/ngx-datatable/#css

我正在使用TemplateRef(而不是演示中的内联模板)

  @ViewChild('Bestand_HdrTpl') Bestand_HdrTpl: TemplateRef<any>;
  @ViewChild('Bestand_Tpl') Bestand_Tpl: TemplateRef<any>;

  setColumns() {
    const dieColmn = [

      {
        cellTemplate: this.Bestand_HdrTpl,
        headerTemplate: this.Bestand_Tpl,
        prop: 'Bestand',
        name: 'LAGER_Bestand',
        canAutoResize: false,
        width: 65,
        cellClass: 'ist-bestand'
      },
      ...
      ,
      {
        cellTemplate: this.Lager_Tpl,
        headerTemplate: this.Lager_HdrTpl,
        prop: 'Lager',
        name: 'ID'
      }
    ];

    return dieColmn;
      

如何实现cellClass-property来调用我的函数?

getCellClass({ row, column, value }): any {

    return {

      // css-class    true oder false
      'ist-bestand': value > 0
    };

  }

我尝试过:

      {
        ...

        width: 65,
        cellClass: 'getCellClass'
      },

    

      {
        ...

        width: 65,
        cellClass: "'getCellClass"'
      },

    

TemplateRef甚至有可能吗?

1 个答案:

答案 0 :(得分:0)

我认为无法将CSS类添加到TemplateRef。

出于实际原因,我全部更改为“在线模板”。