Skip to content

kruno/jquery-tablesorter-filter

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 

Repository files navigation

This tablesorterFilter plugin extends the jQuery TableSorter plugin (http://tablesorter.com), written by Christian Bach, and provides the ability to search the table and filter the results.

USAGE / EXAMPLE

<script type="text/javascript">
    jQuery(document).ready(function() {
        $("#myTable")
        .tablesorter({debug: false, widgets: ['zebra'], sortList: [[0,0]]})
        .tablesorterFilter({filterContainer: "#filter-box",
                            filterClearContainer: "#filter-clear-button",
                            filterColumns: [0]});
    });
</script>

Search: <input name="filter" id="filter-box" value="" maxlength="30" size="30" type="text">
<input id="filter-clear-button" type="submit" value="Clear"/>

<table id="myTable">
<thead>
<tr>
    <th>Last Name</th>
    <th>First Name</th>
    <th>Email</th>
    <th>Web Site</th>
</tr>
</thead>
<tbody>
<tr>
    <td>Smith</td>
    <td>John</td>
    <td>jsmith@gmail.com</td>
    <td>http://www.jsmith.com</td>
</tr>
<tr>
    <td>Doe</td>
    <td>Jason</td>
    <td>jdoe@hotmail.com</td>
    <td>http://www.jdoe.com</td>
</tr>
</tbody>
</table> 


CONFIGURATION

tablesorterFilter takes up to six parameters:

    * filterContainer - (optional) The DOM id of the input box where the user will type the search string. The default is "#filter-box".
    * filterClearContainer - (optional) The DOM id of the button (or image, ...) which will clear the search string and reset the table to it's original, unfiltered state. The default is "#filter-clear-button".
    * filterColumns - (optional) An array of columns, starting at 0, which will be searched. The default is null so all columns will be searched.
    * filterCaseSensitive - (optional) Boolean stating whether the search string is case sensitive. The default is false.
    * filterWaitTime - (optional) Time after last key press to start filtering. The default is 500 (milliseconds).
    * filterFunction - (optional) Custom function to filter by column text. The default is the plugin function has_words.

You may provide mutiple filters (i.e. .tablesorterFilter({filterColumns: [0, 1]}, {filterContainer: "#filter-box-date", filterColumns: [2], filterFunction: filterByDate}.
Search words are separated by spaces, words with a leading dash will be excluded.
Example: "include -exclude" will filter for all rows which do contain the (partitial) word "include" but at the same time do not contain the word "exclude".


REQUIREMENTS

jQuery version 1.2.1 or higher and a slightly modified jquery.tablesorter.js version 2.0.3.  Both are included in this repo.


LICENSE

tablesorter_filter is (c) 2008 Justin Britten (justinbritten at gmail dot com) and is dual licensed under the MIT and GPL licenses.

About

A search/filter plugin which extends the jQuery TableSorter plugin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published