Skip to content

Commit

Permalink
Fix filtered child rows - issue Mottie#89
Browse files Browse the repository at this point in the history
  • Loading branch information
Mottie committed Jun 20, 2012
1 parent 1423d37 commit 8f020a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion docs/example-child-rows-filtered.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
// class name applied to filter row and each input
filter_cssFilter : 'tablesorter-filter',
// search from beginning
filter_startsWith : false
filter_startsWith : false,
// Set this option to false to make the searches case sensitive
filter_ignoreCase : true
}

});
Expand Down
6 changes: 4 additions & 2 deletions js/jquery.tablesorter.widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,18 +204,19 @@ $.tablesorter.addWidget({
l = $tr.length;
// loop through the rows
for (j = 0; j < l; j++) {
// skip child rows
if (reg1.test($tr[j].className)) { continue; }
if (cv === '') {
$tr[j].style.display = '';
} else {
// skip child rows
if (reg1.test($tr[j].className)) { continue; }
r = true;
cr = $tr.eq(j).nextUntil('tr:not(.' + c.cssChildRow + ')');
// so, if "table.config.widgetOptions.filter_childRows" is true and there is
// a match anywhere in the child row, then it will make the row visible
// checked here so the option can be changed dynamically
t = (cr.length && (wo && wo.hasOwnProperty('filter_childRows') &&
typeof wo.filter_childRows !== 'undefined' ? wo.filter_childRows : true)) ? cr.text() : '';
t = wo.filter_ignoreCase ? t.toLocaleLowerCase() : t;
$td = $tr.eq(j).children('td');
for (i = 0; i < cols; i++) {
x = $.trim($td.eq(i).text());
Expand Down Expand Up @@ -293,6 +294,7 @@ $.tablesorter.addWidget({
if (c.debug) {
time = new Date();
}
wo.filter_ignoreCase = wo.filter_ignoreCase !== false; // set default filter_ignoreCase to true
for (i=0; i < cols; i++){
$th = $ths.filter('[data-column="' + i + '"]:last'); // assuming last cell of a column is the main column
sel = (wo.filter_functions && wo.filter_functions[i] && typeof wo.filter_functions[i] !== 'function') || $th.hasClass('filter-select');
Expand Down

0 comments on commit 8f020a5

Please sign in to comment.