Add class to cell/row on condition
-
Hi, I have previously used this:
{ "wpda_search_force_enter": false, "columnDefs": [{ "targets": [1, 3], "visible": false, "searchable": false }, { "targets": [7], "className": "dtCol_lessonStatus", "render": "function(data) { if (data == 'upcoming') return '<span class=\"dtCell_statusUpcoming\">' + data + '</span>'; if (data == 'active') return '<span class=\"dtCell_statusActive\">' + data + '</span>'; if (data == 'expired') return '<span class=\"dtCell_statusExpired\">' + data + '</span>'; }" }] }
But rather than create class in span in the cell, I want to have the cell have the class intead. This is my attempt, but they aren’t working. What have I done wrong?
{ "wpda_search_force_enter": false, "columnDefs": [{ "targets": [1, 3], "visible": false, "searchable": false }, { "targets": [7], "className": "dtCol_lessonStatus", "createdCell": "function(td, cellData, rowData, row, col) { if (cellData == 'upcoming') $(td).addClass('dtCell_statusUpcoming'); if (cellData == 'active') $(td).addClass('dtCell_statusActive'); if (cellData == 'expired') $(td).addClass('dtCell_statusExpired'); }" }], }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Add class to cell/row on condition’ is closed to new replies.