ssuperczynski / ngx-easy-table

The Easiest Angular Table. 12kb gzipped! Tree-shakeable. 55 features and growing!
https://ngx-easy-table.eu
MIT License
371 stars 100 forks source link

how to color a row depending on cell value ? #300

Closed jeanvdr closed 4 years ago

jeanvdr commented 4 years ago

Hi, I would like to color an entire row depending on a cell value of each row. How can I hook the table.API.setRowStyle for this ? Thanks

ssuperczynski commented 4 years ago

You need to use ngAfterViewInit:

  ngAfterViewInit(): void {
    this.data.forEach((row, index) => {
      this.table.apiEvent({
        type: API.setRowStyle,
        value: {
          row: index + 1,
          attr: 'background',
          value: row.age > 30 ? '#fd5e5ed4' : 'green',
        },
      });
    });
  }