Set background color of column
Set background color of column
I would like to change the background color of columns that are editable, but when I do this using the classname, it also changes the background color of that column's header, which I don't want. Is there a way to highlight the td cells but not the th? This is how I currently have it:
DT column
{ "data": "UserFlag", "className": "table-cell-edit" }
CSS
.table-cell-edit{
background-color: lightgoldenrodyellow;
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
See the documentation on DT styling:
https://datatables.net/manual/styling/classes
But if I only want to change the background color of the editable columns, which in my case is a subset of all the columns in the table. It seems like the example mentioned changes style for the entire table.
The method you suggest of using
columns.className
and a CSS style is the correct way to do it.If the whole table is changing, that suggests all cells have
table-cell-edit
on them, or perhaps a parent element such as the table does, since the selector isn't being restricted by node name.Perhaps try using
td.table-cell-edit
? If that doesn't work, we'd need a link to the page.Allan
Thank you, setting my css class as you suggested did the trick.