brunano21 / angular-4-data-table

An Angular 5 data table, with pagination, sorting, expandable rows, row selection, etc. with basic accessibility support.
MIT License
11 stars 19 forks source link

How about coloring by column via dataTableCell? #44

Closed dpadula closed 6 years ago

dpadula commented 6 years ago

Is this possible? In this page https://ggmod.github.io/angular-2-data-table-demo/ the example #3 have a column colored by a function:

    <data-table-column
        [property]="'rating'"
        [header]="'Rating'"
        [sortable]="true"
        [cellColors]="cellColor">
    </data-table-column>

Where the function in the .ts file is:

cellColor(car) {
    return 'rgb(255, 255,' + (155 + Math.floor(100 - ((car.rating - 8.7)/1.3)*100)) + ')';
};

Thanks!

dpadula commented 6 years ago

Is this the correct way?

:host /deep/ .data-column.column-nameColumn { background-color: #ffaaff; }

brunano21 commented 6 years ago

yes, you can colour a specific cell. If you download the entire repo and put the demo up and running, you can see various examples.

Also, you can use both ways of applying cell colour.

dpadula commented 6 years ago

Genius, thanks! I really appreciate this.