DataTable - Color

Certain rows can be styled based on a condition using rowStyleClass. Table below highlights cars that are manufactured before 1990.

IdYearBrandColor
f6b6cc461960FiatRed
92a0b2731962BMWOrange
a437b8a61997RenaultSilver
0ec36b201964RenaultRed
a97a9fba1988FiatOrange
f19be7001980MercedesMaroon
ed4780191987FordOrange
ad0921851998JaguarYellow
bb86e1be1980VolvoBlue
2a8d27971984BMWSilver
<style type="text/css">
    .old {
        background-color: #fca752 !important;
        background-image: none !important;
        color: #000000 !important;
    }
</style>

<p:dataTable var="car" value="#{dtBasicView.cars}" rowStyleClass="#{car.year le 1990 ? 'old' : null}">
    <p:column headerText="Id">
        <h:outputText value="#{car.id}" />
    </p:column>

    <p:column headerText="Year">
        <h:outputText value="#{car.year}" />
    </p:column>

    <p:column headerText="Brand">
        <h:outputText value="#{car.brand}" />
    </p:column>

    <p:column headerText="Color">
        <h:outputText value="#{car.color}" />
    </p:column>
</p:dataTable>