Skip to content

Support for tablesorter Mottie fork at https://github.com/Mottie/tablesorter #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions tablesorter_filter.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Forked version (quartzmo 2012/11/12)
*
* Copyright (c) 2008 Justin Britten justinbritten at gmail.com
*
* Some code was borrowed from:
Expand Down Expand Up @@ -34,7 +36,7 @@
}


function doFilter(table) {
function doFilter(table, allRows) {
if(table.config.debug) { var cacheTime = new Date(); }

// Build multiple filters from input boxes
Expand Down Expand Up @@ -113,7 +115,6 @@

// Walk through all of the table's rows and search.
// Rows which match the string will be pushed into the resultRows array.
var allRows = table.config.cache.row;
var resultRows = [];

var allRowsCount = allRows.length;
Expand Down Expand Up @@ -147,14 +148,13 @@
return table;
};

function clearFilter(table) {
function clearFilter(table, allRows) {
if(table.config.debug) { var cacheTime = new Date(); }

// Reset all filter values
for(var i=0; i < table.config.filter.length; i++)
$(table.config.filter[i].filterContainer).val('').get(0).lastValue = '';

var allRows = table.config.cache.row;

$.tablesorter.clearTableBody(table);

Expand Down Expand Up @@ -198,6 +198,9 @@

var table = this;

var allRows = table.config.cache[0].row.slice();


// Create a timer which gets reset upon every keyup event.
//
// Perform filter only when the timer's wait is reached (user finished typing or paused long enough to elapse the timer).
Expand All @@ -211,7 +214,7 @@

if ((value != inputBox.lastValue) || (override)) {
inputBox.lastValue = value;
doFilter( table );
doFilter( table, allRows );
}
};

Expand Down Expand Up @@ -260,7 +263,7 @@
// Support entering the same filter text after clearing
container[0].lastValue = "";
// TODO: Clear single filter only
doFilter(table);
doFilter(table, allRows);
if(container[0].type != 'hidden')
container.focus();
});
Expand All @@ -269,10 +272,10 @@
}

$(table).bind("doFilter",function() {
doFilter(table);
doFilter(table, allRows);
});
$(table).bind("clearFilter",function() {
clearFilter(table);
clearFilter(table, allRows);
});
});
};
Expand Down