Alternate row color by date (group)
Alternate row color by date (group)
The base style is shading every other row: http://datatables.net/examples/styling/display.html. What I am trying to achieve is to have same color on the rows with the same value and then alternate based on groups.
For example, if I have a column named date and I want to color the whole table based on this column. There are 5 rows that date = "06/29/2015", following by 3 rows that date = "06/26/2015", following by 4 rows that date = "06/22/2015" (already sorted by date). Can I shade those rows that date = "06/29/2015" and "06/22/2015" and alternate like this.
Is there a clean or simple way to do it? Thanks for any advice.
Answers
Anyone knows?
Id say use rowCallback: https://datatables.net/reference/option/rowCallback
Check if its first row and add class1
If its not first row look to last row maybe with
.prev()
and if its same add class1 if its not the same add whatever class is opposite of the previous siblings class...