Reputation: 709
I am using tablesorter dropdown using which I am able to select one element from it. I want to be able to select multiple elements. Is there a way to do it using table sorter ?
I tried looking up here but I am not sure if it says of any direct way to do it. Also this issue seems to suggest that there is no direct way?
EDIT:
Code
filter_functions : {
0 : {
"a" : function(e, n, f, i, $r) { return e===f; },
"b" : function(e, n, f, i, $r) { return e===f; },
"c" : function(e, n, f, i, $r) { return e===f; },
"d" : function(e, n, f, i, $r) { return e===f; }
}
Upvotes: 1
Views: 1126
Reputation: 86433
You can use the filter_formatter
option along with the extra filter-formatter select2 code to use the select2 plugin. Here is a demo.
filter_formatter : {
// default settings on first column
0 : function($cell, indx){
return $.tablesorter.filterFormatter.select2( $cell, indx, {
// *** select2 filter formatter options ***
cellText : '', // Text (wrapped in a label element)
match : true, // adds "filter-match" to header & modifies search
value : [], // initial select2 values
// *** ANY select2 options can be included below ***
// (showing default settings for this formatter code)
multiple : true, // allow multiple selections
width : '100%' // reduce this width if you add cellText
});
}
}
Note: Please be aware that the $.tablesorter.filterFormatter.select2
function does not yet work with select2 v4.0.0 beta. Use select2 v3.4.6 included with the repsitory.
Upvotes: 2