Set a td class based on a data value
Set a td class based on a data value
Hi, I have a dataset which looks like this:
"Name":"John Doe",
"Location":"Atlanta",
"Priority":"High"
The priority field have values low, medium, high.
In the table, I want the first cell to have a corresponding background color, e.g. a green background for "low", a yellow for "medium" and red for "high". Can I get this datavalue to be a class in the first table column, like "class":"medium"
Then I would just style the .medium style in css, with a background color.
Is this possible?
Answers
You can use
columns.createdCell
to do it. Or if you want to do it dynamically, you could use the selectors as functions in 1.10.3.Allan