How to handle database null values in jquery datatable
Add defaultContent in the options while initializing the data table. For more details
columns.defaultContent
Example from the official documentation:
$('#example').dataTable( {
"columns": [
null,
null,
null,
{
"data": "first_name", // can be null or undefined
"defaultContent": "<i>Not set</i>"
}
]
} );
You can use mRender
to specify the display in the event of a null value:
{
"mData": "FeeCompany"
'mRender': function (data, type, full) {
if (full[7] !== null) {
return full[7];
}else{
return '';
}
},