I am currently working on a datatable which finally seems to work exactly the way I want, however one issue remains, please see my screenshots below:
As you can see, I am adding custom colors in the column STATUS based on the actual status value using the following code:
'columnDefs': [ {
'targets': 3,
'createdCell': function (td, cellData, rowData, row, col) {
if ( cellData == 'Pending' ) {
$(td).css('color', '#e27522'),
$(td).css('font-weight', 'bold')
}
else if ( cellData == 'Confirmed' ) {
$(td).css('color', 'green'),
$(td).css('font-weight', 'bold')
}
else if ( cellData == 'Accepted' ) {
$(td).css('color', 'lightgreen'),
$(td).css('font-weight', 'bold')
}}
},
{ responsivePriority: 1, targets: 5 }]
This works great, however these properties are getting removed on responsive mode.
Responsive mode:
How can I maintain these color values for status? Here my full Javascript:
<script type="text/javascript">
$(document).ready(function() {
$('#jquery-datatable-ajax-php').DataTable({
'processing': true,
'responsive': true,
'serverSide': true,
'serverMethod': 'post',
'order': [[5, 'desc']],
'ajax': {
'url':'datatable.php'
},
'columns': [
{ data: 'client_name' },
{ data: 'quote_number' },
{ data: 'project' },
{ data: 'status' },
{ data: 'quote_total', render: $.fn.dataTable.render.number(',', '.', 2,), className: 'dt-body-right'},
{ data: 'id', 'name': 'id', fnCreatedCell: function (nTd, sData, oData, iRow, iCol) {$(nTd).html("<a class='link' href='/quotes/view/"+oData.id+"?nocache=<?php echo time()?>'>View</a>");}}
],
'columnDefs': [ {
'targets': 3,
'createdCell': function (td, cellData, rowData, row, col) {
if ( cellData == 'Pending' ) {
$(td).css('color', '#e27522'),
$(td).css('font-weight', 'bold')
}
else if ( cellData == 'Confirmed' ) {
$(td).css('color', 'green'),
$(td).css('font-weight', 'bold')
}
else if ( cellData == 'Accepted' ) {
$(td).css('color', 'lightgreen'),
$(td).css('font-weight', 'bold')
}}
},
{ responsivePriority: 1, targets: 5 }]
});
} );
</script>
Some expert help would be greatly appreciated, thank you.

