Table Row Conditional Styling?
Table Row Conditional Styling?
Drum998
Posts: 14Questions: 6Answers: 0
Hi,
Is it possible to alter the styling of a row in the datatable depending on the data in one of its cells? I'm trying to colour the table rows according to a code in the incoming data. Is this possible? If so, could someone please point me in the right direction?
Thanks
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hello @Drum998,
since this question pops up now and then, I made an example on codepen of how this can be done. Here's the link to the example.
Codepen: Conditional row styling
Think it's also possible with the
columns.createdCell
, but I haven't tested that out.You, sir, are a gentleman and a scholar! Thank you!
You're welcome.
I tried the method pointed to above by F12Magic and had some limited success, but I was seeing some odd results in my actual application using json data and adding further colours. I ended up using another method using createdRow and I am adding it here for future reference.
This method has the possible advantage that the field supplying the condition need not be visible.