vr3w3c9
vr3w3c9

Reputation: 1178

Changing background color for non-header cells in column of p:dataTable

I would like to know how to set up background color for a specific column in a datatable.I have tried the below css code

.mystyle.ui-datatable .ui-datatable-data td, .mystyle.ui-datatable .ui-datatable-data td{
background-color:#B5D3A5;   
}  

But the above seems to change the background color for all the columns in the datatable. Please let me know how to change the background color for a specific column in the datatable. Thanks in Advance

Upvotes: 3

Views: 9742

Answers (2)

java
java

Reputation: 111

Use headerClass attribute of p:dataTable for header style and use inline style for your requierd column as style="text-align:center;background-color:red"

Upvotes: 1

Matt Handy
Matt Handy

Reputation: 30025

You can use the style and styleClass attributes of p:column for this:

<p:column style="background-color: red" ...>

This will colorize table cells and header cells.

If you don't want to change header cells you could do the following:

Give the column a styleClass attribute:

<p:column styleClass="foo" ...>

And then add the following style definition to your css/html:

td.foo {
    background-color: red;
}

Upvotes: 3

Related Questions