Our product owner would like the our empty tables to display just table header when there is no data in table. I can't seem to prevent dataTable from creating a row with "empty..." message.
Here is the code I use to initialize the dataTable. I know some things here are wrong. I have been experimenting. :)
$('#InBox').dataTable({
"bFilter": false,
"bPaginate": false,
"bLengthChange": false,
"bInfo": false,
"oLanguage": {
"sEmptyTable": '',
"sInfoEmpty": ''
}
});
Here is some code I tried to put in the init function of the dataTable, but I am not sure how to get it to work.
/* Table is empty - create a row with an empty message in it */
var anRows[0] = document.createElement('tr');
if (typeof oSettings.asStripClasses[0] != 'undefined') {
anRows[0].className = oSettings.asStripClasses[0];
}
var nTd = document.createElement('td');
nTd.setAttribute('valign', "top");
nTd.colSpan = oSettings.aoColumns.length;
nTd.className = oSettings.oClasses.sRowEmpty;
if (oSettings.fnRecordsTotal() > 0) {
if (oSettings.oLanguage.sZeroFilterRecords.indexOf("_MAX_") != -1)
oSettings.oLanguage.sZeroFilterRecords = oSettings.oLanguage.sZeroFilterRecords.replace("_MAX_", oSettings.fnRecordsTotal());
nTd.innerHTML = oSettings.oLanguage.sZeroFilterRecords;
} else {
nTd.innerHTML = oSettings.oLanguage.sZeroRecords;
}
anRows[iRowCount].appendChild(nTd);
Dan
try this
$('#InBox').dataTable({
"bFilter": false,
"bPaginate": false,
"bLengthChange": false,
"bInfo": false,
"oLanguage": {
"sEmptyTable": '',
"sInfoEmpty": ''
},
"sEmptyTable": "There are no records",
});
otherwise you can try this
$('#InBox').dataTable({
"bFilter": false,
"bPaginate": false,
"bLengthChange": false,
"bInfo": false,
"oLanguage": {
"sEmptyTable": '',
"sInfoEmpty": ''
}
});
$('.dataTables_empty').html("No record found.");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With