right sytnax for addClass to the row depending on data
right sytnax for addClass to the row depending on data
i'm using datatables Editor and love it. often i struggle with the syntax (my javascript is not that good). maybe someone can help me out. i'm sure datatable can handle this. thx a lot.
i want to add a class to the row (tr) depending on data. so i tried this, but doesn't work:
var thisDataTable = $('table.editorTable').DataTable({
ajax: 'editor-date-ssp.php',
columns: [
// Kategorie
{ data: null,
render: function (data, type, row) {
if (data.date_status == 'offline') { $(row).addClass('-offline'); }
return data.date_kategorie;
},
editField: 'thri_date.date_kategorie',
},
}); // thisDataTable
Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @mdesign ,
You can use
createdRow
for that, there's an example showing exactly that.Cheers,
Colin
thx colin,
thats exactly what i tried before. but this doesn't set any class.
Yep, but you're doing it in
columns.render
, I'm saying move that code in tocreatedRow
- that's where you add classes to the cell.thx again colin, but that doesn't work either. i will try to post the hole code here. i would need this in other codes too, so it would be great for me to have one working example and understanding the concept.
Hi @mdesign ,
I'm not seeing
createdRow
in that code, nor addaddClass
! This example here is showing what you're after, as I explained.Cheers,
Colin
thx colin. i got it now. the js-bin example helped a lot.