Hello,
How to change the color of the rows in the datatable ?
Thanks ahead
DataTable Rows color
This code works:
Code: Select all
<style>
.first-row {
background-color: #ffffff !important;
background-image: none !important;
color: #000000 !important;
}
.second-row {
background-color: #0000ff !important;
background-image: none !important;
color: #000000 !important;
}
</style>
...
<p:dataTable
...
rowIndexVar="rowIndex"
rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'first-row' : 'second-row'}">
I have not tried this code, it surely works but looks a bit longer.
You can find a better answer in the user guide page 143 (DataTable skinning). There are two CSS properties .ui-datatable-even and .ui-datatable-odd which you can use and set the background color of whether your odd or even rows .
here is how it looks like (for even rows) :
Hope this will help
You can find a better answer in the user guide page 143 (DataTable skinning). There are two CSS properties .ui-datatable-even and .ui-datatable-odd which you can use and set the background color of whether your odd or even rows .
here is how it looks like (for even rows) :
Code: Select all
<style type="text/css">
.ui-datatable, .ui-datatable-even {
background: #3a8104;
}
</style>
Eclipse Helios 3.6 | Glassfish 3.1 | PrimeFaces 2.2.1
Thanks for it, it works fine!
anatolse wrote:This code works:Code: Select all
<style> .first-row { background-color: #ffffff !important; background-image: none !important; color: #000000 !important; } .second-row { background-color: #0000ff !important; background-image: none !important; color: #000000 !important; } </style> ... <p:dataTable ... rowIndexVar="rowIndex" rowStyleClass="#{(rowIndex mod 2) eq 0 ? 'first-row' : 'second-row'}">
Glassifish 4.1
JSF 2.2
Primefaces 6.1
JSF 2.2
Primefaces 6.1
-
- Information
-
Who is online
Users browsing this forum: No registered users and 16 guests