1

I have done this many times before in other platforms where a data table is rendered through a loop and I had more control. However, h:dataTable is more high level and I can't or don't know how to embed a function on the row level that will color the background of the row differently based on whether it is an even or odd numbered row.

Is it possible and how can I rows in h:dataTable alternate color?

amphibient
  • 29,770
  • 54
  • 146
  • 240
  • possible duplicate of [JSF: Changing datatable cell color dynamically](http://stackoverflow.com/questions/11038769/jsf-changing-datatable-cell-color-dynamically) – Kukeltje Feb 05 '15 at 22:28
  • the linked answer does not really answer. see the accepted answer here – amphibient Feb 05 '15 at 23:16
  • It does (is accepted and 7 upvotes) if you read on… and the see also provides even more info.. It e.g. states: _With the standard JSF component you need to supply a comma-separated string of all row classes. This can look something like this…_ and with using an EL as stated there, you could even give each row a specific class/color… – Kukeltje Feb 05 '15 at 23:58

1 Answers1

3

Just have two classes oddRow and evenRow in the css having different background colors then use rowClasses="oddRow,evenRow" to apply the different background of the rows

user3278647
  • 494
  • 1
  • 4
  • 9