0

I have this datatable that loadied from the datatabase, here is :

<p:dataTable id="cars" var="car" value="#{acceuilUserController.lc_maj}" tableStyle="width:auto">  
 <p:column headerText="Commande N° : " style="width:100px">  
 <h:outputText value="#{car.commande.id}" />  
 </p:column>  
 <p:column headerText="Date de mise à jour : " style="width:100px">  
 <h:outputText value="#{car.dateMaj}" />  
 </p:column> 
 <p:column headerText="Decision : " style="width:100px">  
 <h:outputText value="#{car.decison}" />  
 </p:column> 
 <p:column headerText="Etat : " style="width:100px">  
 <h:outputText value="#{car.etat}" />  
 </p:column> 
</p:dataTable>    

I have another attribut car.lu that accept two values :true or false, I want when it is false the line flashes and become colored with red how I can achieve this?

1 Answer 1

0

You can achieve this using conditional coloring:

<p:dataTable id="cars" var="car" value="#{acceuilUserController.lc_maj}" tableStyle="width:auto" rowStyleClass=#{(car.lu == false) ? 'red' : null}>
    <p:column headerText="Commande N° : " style="width:100px">
        <h:outputText value="#{car.commande.id}" />
    </p:column>

    <p:column headerText="Date de mise à jour : " style="width:100px">
        <h:outputText value="#{car.dateMaj}" />
    </p:column>

    <p:column headerText="Decision : " style="width:100px">
        <h:outputText value="#{car.decison}" />
    </p:column>

    <p:column headerText="Etat : " style="width:100px">
        <h:outputText value="#{car.etat}" />
    </p:column>
</p:dataTable>

If car.lu returns false the style class red is applied to the row. So you have to have this in your CSS:

.red {
    background-color: red;
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.