I'm using jQuery plug-in jquery-tablesorter-filter. It works great. I have problem when I want to count how many rows after the table is filtered.
$("#tblContainer").tablesorter({
debug: false,
sortList: [
[0, 0]
],
widgets: ['zebra']
}).tablesorterFilter({
filterContainer: $("#filterBox"),
filterColumns: [1, 2],
filterCaseSensitive: false
});
Here's the code to count the filtered rows (rows that are currently on the screen). But it doesn't give me the correct result. It gave the last count of filtered rows instead of the current counts. It always give result with one key stroke behind.
$("#filterBox").keyup(function () {
var textLength = $("#filterBox").val().length;
if (textLength > 0) {
var rowCount = $("#tblContainer tr:visible").length;
$("#countCourseRow").html(" found " + rowCount);
} else {
$("#countCourseRow").html("");
}
});
What's wrong with the built in events: http://mottie.github.com/tablesorter/docs/example-option-show-processing.html
The example will look like this:
$("#tblContainer").tablesorter({
debug: false,
sortList: [
[0, 0]
],
widgets: ['zebra']
}).bind('filterEnd', function() {
$("#countCourseRow").html("");
$("#countCourseRow").html("found " + $('#myTable tr:visible').length);
});
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