Thursday, January 5, 2012

jQuery quickSearch Dynamic Row Count

I just spent an hour struggling to find a solution to what seemed to be a fairly simple problem. I have a webpage comprised primarily of a large table and a textbox which uses a jQuery plugin quickSearch to filter the table. What I wanted then was a dynamic count of the rows returned by quickSearch. In the end this was accomplished wih the following code in the HTML:
Results: <p id="count"></p>
And the addition of this argument to the quickSearch function directly after the "loader:" argument:
onAfter: function() {
document.getElementById("count").innerHTML=($('tr:visible').length-1);
}
Now, if one's quickSearch use were doing something other than simply setting rows to hidden then this example may not work exactly as shown, but this may be useful for other applications as well.

No comments:

Post a Comment