addclass to cell
addclass to cell
Hi,
I am having a column where I add a icon for deleting or canceling depedning on the status of the row-item. I also need to add a class, this is what does not work.
Here is my code for this column:
{
data: null,
render: function (data) {
if(data.mytab.Re_Status < 50){
return '<i class="fa fa-trash btn-kl" style="color: #90a51d" title="Element löschen" />';
} else if (data.mytab.Re_Status < 90 && data.mytab.Re_Art_Text != 'Storno') {
return '<i class="fa fa-times btn-kl" style="color: red" title="Element stornieren" />';
} else {
return ' ';
}
},
createdCell: function (td, cellData, rowData, row, col) {
if ( cellData < 50 ) { $(td).addClass('ausgreloeschen dt-center editor-edit');
} else if (cellData < 90) { $(td).addClass('ausgrestorno dt-center editor-edit');
}
},
orderable: false,
cursor: 'pointer'
},
If i set
data: mytab.Re_Status
the whole datatable does not work anymore (it is not rendered, although data is loaded).
Any idea how to solve this?
Thanks
Max
Answers
Have a look at
createRow
, there's an example there similar to what you're after. There it's adding a class to the row, but it just needs a tighter selector to add it onto the cell.This example is using
columns.render
, so may also be handy.Colin
thanks, solved it by optiming the render-part: