I think it would be beneficial if there were separate properties to display different messages if there is no data existing in the table versus no data matching the current filter.
Then in my initialise statement on the front end, I can customize it by adding the "sZeroFilterRecords" attribute within the oLanguage section.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"oLanguage": {
"sZeroFilterRecords": "No records matched out of _MAX_ total records"
}
} );
} );
[/code]
What I've done is just a little bit different, in order to try and maintain the current state of affairs with regard to the various translations that are available for DataTables. Specifically I've got:
"sZeroRecords": "No matching records found",
"sEmptyTable": "No data available in table",
sEmptyTable is used when the table is truly empty, and sZeroRecords when there is no matching filter - which I think fits in with the language a little better. I've retained your suggestion of being able to use _MAX_ for the filtering option - nice touch :-)
Replies
I think that is not a bad idea at all. I'll look into adding this in the next release. Thanks for suggesting it!
Regards,
Allan
I created a sZeroFilterRecords variable and made the following changes...
- Added it to the oLanguage declaration:
[code]
this.oLanguage = {
"sProcessing": "Processing...",
"sLengthMenu": "Show _MENU_ items",
"sZeroRecords": "No matching records found",
"sZeroFilterRecords": "No matching results from _MAX_ total results",
"sInfo": "Showing _START_ - _END_ of _TOTAL_ items",
"sInfoEmpty": "Showing 0 to 0 of 0 entries",
"sInfoFiltered": "(filtered from _MAX_ total items)",
"sInfoPostFix": "",
"sSearch": "Search:",
"sUrl": "",
"oPaginate": {
"sFirst": "First",
"sPrevious": "<",
"sNext": ">",
"sLast": "Last"
}
};
[/code]
- Added it to the _fnLanguageProcess...
[code]
function _fnLanguageProcess(oSettings, oLanguage, bInit) {
_fnMap(oSettings.oLanguage, oLanguage, 'sProcessing');
_fnMap(oSettings.oLanguage, oLanguage, 'sLengthMenu');
_fnMap(oSettings.oLanguage, oLanguage, 'sZeroRecords');
_fnMap(oSettings.oLanguage, oLanguage, 'sZeroFilterRecords');
_fnMap(oSettings.oLanguage, oLanguage, 'sInfo');
_fnMap(oSettings.oLanguage, oLanguage, 'sInfoEmpty');
_fnMap(oSettings.oLanguage, oLanguage, 'sInfoFiltered');
_fnMap(oSettings.oLanguage, oLanguage, 'sInfoPostFix');
_fnMap(oSettings.oLanguage, oLanguage, 'sSearch');
if (typeof oLanguage.oPaginate != 'undefined') {
_fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sFirst');
_fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sPrevious');
_fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sNext');
_fnMap(oSettings.oLanguage.oPaginate, oLanguage.oPaginate, 'sLast');
}
if (bInit) {
_fnInitalise(oSettings);
}
}
[/code]
- Added it to the "table is empty" message
[code]
/* Table is empty - create a row with an empty message in it */
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);
[/code]
Then in my initialise statement on the front end, I can customize it by adding the "sZeroFilterRecords" attribute within the oLanguage section.
[code]
$(document).ready(function() {
$('#example').dataTable( {
"oLanguage": {
"sZeroFilterRecords": "No records matched out of _MAX_ total records"
}
} );
} );
[/code]
What I've done is just a little bit different, in order to try and maintain the current state of affairs with regard to the various translations that are available for DataTables. Specifically I've got:
"sZeroRecords": "No matching records found",
"sEmptyTable": "No data available in table",
sEmptyTable is used when the table is truly empty, and sZeroRecords when there is no matching filter - which I think fits in with the language a little better. I've retained your suggestion of being able to use _MAX_ for the filtering option - nice touch :-)
Regards,
Allan