How do I add a class to a specific column when using the columns.every function?
How do I add a class to a specific column when using the columns.every function?
taylor5042
Posts: 21Questions: 6Answers: 0
I have the following code which works when the column 0 is not hidden.
What I am trying to do is check the values in a hidden column 0 and change the class of column 1 based on the text value in column 0.
I am open to doing this another way, like with rows.every if that is easier, but I am not clear on how to accomplish this.
table.columns(0).every(function() {
this.nodes().to$().each(function() {
if ($(this).text() == 'sometext') {
} else {
$(this).next('td').addClass('highlight');
}
});
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
The problem is
$(this).next('td')
. There is nonext
element since DataTables has removed the hidden column from the document.I think I'd do it like this:
Allan
Allan,
Thanks so much for your help, it works perfect!
I couldn't grasp how to do that from the forums/documentation.
Is there anything specific that you think would be useful for me to add to the documentation to explain it a bit more?
It is slightly more convoluted than I would like that case - there will be other ways to do it, but I think that's probably one of the most efficient.
Allan