Tech, Gaming and Food Enthusiast
Client side searching with jQuery
In my previous post about sorting data I explained the brilliance of client side sorting using jQuery. When researching various other jQuery plugins I discovered tablesearch which can be invaluable when searching smaller data sets.
As in my previous jQuery post we will start with a standard HTML table, giving it an id of “myTable” of course if you wish to use multiple instances on the same page a class is a far more elegant solution.
Creating a tablesearch is as easy as:
$('#myTable').tableSearch();
The tableSearch plugin has a small error handling facility in that one can set default messages to display when no searching data is found or when a field is empty.
$('#myTable').tableSearch({
empty: "This is an empty field error message",
notFound: "This is a not found error message"
});
As with the tablesorter plugin, any column can be removed from the search using the tableSearch config.
$('myTable').tableSearch({
ignore: "myColumnName"
});
There will be more functionality built in in future releases such as turbo and selector. I would recommend tablesearch to anyone thinking of searching small data structures
For release documentation and downloads visit the plugin website
| Print article | This entry was posted by Matt on March 20, 2010 at 1:27 pm, and is filed under JavaScript, Searching. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |