Assign TD background color based in a column value
Assign TD background color based in a column value
henpat
Posts: 4Questions: 2Answers: 0
Hi all
I have tow columns
"Color_applied"(visible) - "colorHEX" (hide)
I need to fill all "Color_applied" TD with a background-color = "value of the colorHEX column"
Any help is welcome
Cheers
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Yes, it can be done, but it's not native to jqDataTables per se and it involves adding more json data than is rendered. I'm sure there are other ways to do this, but this is how I've done it.
You don't need to hide your colorHEX column, just don't need to make it a column at all. You pass it in the json, but not as a table column.
When you define your columns
When you send your Json
The trick is using a rowCallback. something like this
Thanks!!! this works, rowCallback was the trick!
Only change I did:
$("td:eq(0)", row)