Having dataTables_info reflect number of hidden rows
Having dataTables_info reflect number of hidden rows
I have implemented a filter external to DataTables to hide rows that match specific criterion. However, the dataTables_info block still reports hidden rows in the number of displayed rows as well as in the total rows count. For example, I have 70 total records but 52 of them (TRs) are hidden rows:
[code]
Showing 1 to 70 of 70 entries
[/code]
How would I go about making DataTables ignore hidden rows in the displayed and total row counts?
This is my current initialization of DataTables:
[code]
$('.InfoTable').each(function () {
if ($(this).find('tbody:first > tr').length > 1) {
$(this).dataTable({
"bPaginate": false,
"oSearch": { "sSearch": searchString }
});
}
});
[/code]
[code]
Showing 1 to 70 of 70 entries
[/code]
How would I go about making DataTables ignore hidden rows in the displayed and total row counts?
This is my current initialization of DataTables:
[code]
$('.InfoTable').each(function () {
if ($(this).find('tbody:first > tr').length > 1) {
$(this).dataTable({
"bPaginate": false,
"oSearch": { "sSearch": searchString }
});
}
});
[/code]
This discussion has been closed.
Replies
Allan
I tried to write a custom afnFiltering, but it just isn't working correctly. Of course, my attempt may not be a good one:
[code]
$.fn.dataTableExt.afnFiltering.push(
function (oSettings, aData, iDataIndex) {
if ($('.InfoTable > tbody').find('tr:eq(' + iDataIndex + ')').is(':hidden'))
return false;
else
return true;
}
);
if ($(this).find('tbody:first > tr').length > 1) {
$(this).dataTable({
"bPaginate": false,
"oSearch": { "sSearch": searchString }
});
}
$('#showArchiveItems').change(function () {
if ($('.archiveItem:first').is(":hidden")) {
$('.archiveItem').each(function () {
$(this).show();
});
}
else {
$('.archiveItem').each(function () {
$(this).hide();
});
}
var oTable = $('.InfoTable:first').dataTable();
oTable.fnDraw();
});
[/code]