I use jquery picnet table filter - http://www.picnet.com.au/picnet-table-filter.html
I need to display count of rows currently visible, so I need to react to each filtering event.
There are two options which should serve as callback - filteringRows and filteredRows.
However, I tried both of them and it didn't work out. I got the callback function triggered only sometimes. Finally I have a working solution -
$('#myTable .filters').change(function(){ setTimeout( 'load_num_rows()', 500 ) })
.keyup(function(){ setTimeout( 'load_num_rows()', 500 ) });
What bothers me is that this solution is obviously not callback. This is waiting 500ms for the filtering to finish, but if there would be a lot of rows and the filtering would take a little more than 500ms, then I wouldn't get the result right.
What I tried is
$('#tb_list_reports').tableFilter({filteredRows: function(){ 'load_num_rows()' }});
and
$('#tb_list_reports').tableFilter({filteredRows: function(){setTimeout( 'load_num_rows()', 500 )}});
and the same with option filteringRows. None of them works, the number of rows is not updated. I have tried console.log() and it seems they are not even triggered when I filter rows, and also when I have these options set, I get some strange behaviour - sometimes I reload the page, there is no filtering set and yet I don't get anything displayed until the third reload.
Have you any suggestions on what should I try?
This works for me:
filteredRows: function(filterStates) {
running_total = $("#assets tbody tr").filter(":visible").length;
$("#total_rows_returned").html(running_total);
}