Aishwarya Pal
Aishwarya Pal

Reputation: 21

How to change row color in p:dataTable depending on column value

            <p:dataTable id="test" value="#{test.attLogList}"
                 var="item" 
                 selection="#{test.searchedAttLogList}"
                 rowStyleClass="#{item.name eq 'abb' ? 'Closed' : null}"
                 rowKey="#{item.employeeNumber}">

            <p:column sortBy="#{item.employeeNumber}"
                headerText="#{o:translate('Employee')}">
                <h:outputText value="#{item.employeeNumber} " />
            </p:column>

css tag is

<style type="text/css">
        .Closed {
            background-color: #FF0000 !important;
            color: #000000 !important;
        }
</style>

I want to change row color in data table depend upon condition.Below code is working but only for First row it is not applying for remaining rows.The condition is applying for first row of datatable. kindly help me.

closed is a css tag

Upvotes: 1

Views: 4369

Answers (1)

fjkjava
fjkjava

Reputation: 1464

This worked for me

.yellowRaw {
    background: yellow  !important;
}
<p:dataTable rowStyleClass="#{not empty position.replacedBy?'yellowRaw':''}" ...>

Upvotes: 1

Related Questions