created row callback could not highlight particular cell value
created row callback could not highlight particular cell value
anant30
Posts: 7Questions: 4Answers: 0
I am trying to highlight the cell values which are 'null'.
So when i run following code snippet, instead of highlighting null, it highlights the whole column which are not null.
"createdRow": function (row, data, index) {
if (data[7] = 'null') {
$('td', row).eq(7).addClass('highlight');
}
}
not sure why this is happening. can you help me find a solution?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I suspect the problem is here:
if (data[7] = 'null')
Using one
=
is an assignment not a comparison. I seem to make this mistake quite often tooAn you probably don't want null in quotes. Maybe something like this:
if (data[7] === null)
If this doesn't help then please post a test case with a sample of your data and
createdRow
code.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Oh ya, thanks Kevin!
and I tried if (data[7] === null) though it still highlighted the whole column.
But the following worked!
Yes, the
data
parameter passed in is the original data source, so if you are using objects, then you would need to get the data from as an object, not an array.Allan