-
Notifications
You must be signed in to change notification settings - Fork 753
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
Apply Filter not to all tables #743
Comments
I downgraded to 2.15.14, and it works in this version too. |
Hi @megatom! When you use if ( $( '.sortableFilter' ).length ){
// Update the list of widgets to apply to the table (add or remove)
$( '.sortableFilter' ).each( function() {
var $table = $( this );
// push filter adds the widget to the end of the list of widget
// using widgets = [ 'filter' ] removes all other widgets, except filter
$table.data( 'tablesorter' ).widgets.push( 'filter' );
$table.trigger( 'applyWidgets' );
});
return false;
} |
This seems not to work. |
Make sure to add that code after the tablesorter initialization code. |
It is after init: (In 2.15 it worked fine...) $(".sortable").tablesorter({ if ( $( '.sortableFilter' ).length ){ |
The difference might be due to the timing of when the plugin gets initialized. It might be better to try this code: $(".sortable").tablesorter({
cancelSelection: false,
widgets: [ 'stickyHeaders' ],
selectorHeaders: 'thead th, thead td',
widgetOptions : {
stickyHeaders_offset : 30,
stickyHeaders_addResizeEvent : true
},
initialized: function(table){
var $table = $(table);
if ( $table.hasClass('sortableFilter') ) {
$table.data( 'tablesorter' ).widgets.push( 'filter' );
$table.trigger( 'applyWidgets' );
}
}
}); I'll see what I can do to make this more efficient, like just adding a table class name |
I tried the new code, but still dont work :( |
I am really surprised to see that the filter appears on first time i click on an header to sort a column. |
Apparently, I needed to include a setTimeout to get it to work (updated demo): $('table').tablesorter({
cancelSelection: false,
widgets: ['stickyHeaders'],
selectorHeaders: 'thead th, thead td',
widgetOptions: {
stickyHeaders_offset: 30,
stickyHeaders_addResizeEvent: true
},
initialized: function (table) {
var $table = $(table);
if ($table.hasClass('sortableFilter')) {
table.config.widgets.push('filter');
setTimeout(function(){
$table.trigger('applyWidgets');
}, 1);
}
}
}); Like I said, this will only be a temporary work around until I add a feature to use the table class name to include widgets. |
In 2.16 this workaround helps, but 2.17 still throws error on typing into filter input: TypeError: e.lastSearch is undefined |
In Version 2.14 i used following code to apply filter only on specified tables.
But this code do not work in 2.16 and 2.17.
I cannot find any changes made to filter that uses different code.
Is there any solution?
Maybe you can add an option to apply filter only on specified classes?
The text was updated successfully, but these errors were encountered: