Datatables 2.0.0 "stripeClasses" removal
Datatables 2.0.0 "stripeClasses" removal
krutovdl
Posts: 47Questions: 9Answers: 1
Since the "stripeClasses" was removed from the new Datatables version, what is now the proper way to capture every odd and even row in order to changes their background color? Please provide examples.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Use CSS's
:nth-child()
pseudo selector.This is the default CSS for DataTables row striping.
Allan
This is the old code:
tr.odd {
--bs-table-bg: lightcyan;
}
tr.even {
--bs-table-bg: #c5fbfb;
}
Here is the new code:
-tbody->-tr:nth-child(2n+1)-{">-tbody->-tr:nth-child(2n+1)-{" href="#tbl->-tbody->-tr:nth-child(2n+1)-{">tbl > tbody > tr:nth-child(2n+1) {
}
-tbody->-tr:nth-child(2n)-{">-tbody->-tr:nth-child(2n)-{" href="#tbl->-tbody->-tr:nth-child(2n)-{">tbl > tbody > tr:nth-child(2n) {
}
This worked well except now the column widths are no longer behaving properly. Now all columns set to "visible: false" are indeed not visible but they are taking up the column width on the table. Which creates an appearance of the visible columns width being cut in half.
Please disregard the latter comments. The issue table with issue was fixed after stopping and restarting the debug session. Please close this discussion. Thank you.