3

Is there a way to customize the color of single cells in ngx-datatable? I see that getCellClass is only helping me customize the color for the entire row. Pasting what I currently have here below -

TS file -

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

return {
  'cell-color': this.findModification(row)
};
}


findModification(row)
{

if(mytestJSON[row._id].length!=0) {
  return true;
}
else {
  return false;
}
}

I have this in my css file to change color:

/deep/ .cell-color 
{
    background-color: blue;
}

HTML file snippet:

<ngx-datatable
  class="material pointer"
  [rows]="data"
  [columnMode]="'force'"
  [headerHeight]="50"
  [footerHeight]="0"
  [rowHeight]="'auto'"
  [limit]="10"
  [selectionType]="'single'"
  [scrollbarH]="true"

   >

  <ngx-datatable-column  [cellClass]="getCellClass" *ngFor="let col of myColumns" prop={{col.prop}}>
    <ng-template  let-column="col" ngx-datatable-header-template>
       {{col.name}}
    </ng-template>
  </ngx-datatable-column>

</ngx-datatable>
srao
  • 111
  • 1
  • 9

0 Answers0