Is there a way to make className apply only to the table cells in a column, and not the header field
Is there a way to make className apply only to the table cells in a column, and not the header field
paulh736
Posts: 9Questions: 6Answers: 0
https://live.datatables.net/veyasecu/1/
I'm using the className property on my columns to set the text colour of the values in the fields. But it also changes the text colour of the header field. Is there a way to apply a class to just the data fields, and leave the header field with the default text colour?
This question has an accepted answers - jump to answer
Answers
@paulh736
You only need to put
tbody
in the selector like:tbody .redText { color: red }
tbody .greenText { color: green }
No - the
columns.className
is applied to the header, footer (if there is one) and body. There isn't a way in DataTables at the moment to limit it to just one section.The easiest option is to use CSS as @rodriformiga says.
Another option is to use
columns.createdCell
to add a class to the cell when it is added.Allan
using "rowCallback":
https://live.datatables.net/jogogego/1/edit
or the one above by @rodriformiga:
https://live.datatables.net/wiqapagu/1/edit