(conditional cell formatting) add class to cell (td) from within render function

(conditional cell formatting) add class to cell (td) from within render function

xtech_devxtech_dev Posts: 25Questions: 11Answers: 0

I would like to achieve conditional formatting based on cell value. Is it possible to add class to td element from inside of render function?

I have tried but it seems to not have any effect.

function (data, type, row, meta) {
   if (type == "display") {
      var $table = $(meta.settings.oInstance.api().table().node());
      var $td = $table.find('tr:eq(' + meta.row + ') > td:eq(' + meta.col + ')');
       $td.addClass('bkg-red');
   }
}

I have seen solution with rowCallback option (https://datatables.net/forums/discussion/comment/110916/#Comment_110916) but i would prefer to keep render logic in "one place".

Any ideas?

It Man.

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.