-
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
tablesorter.filterFormatter.select2 doesn't work with special characters #796
Comments
Hi @gurditta! It looks like the main issue is that the filterFormatter was written for select2 v3.4.6. When the value contains a comma (e.g. It looks like the issue was fixed in the latest version of select2, v4.0.0 beta 2, where the result is the proper string So what happens is that when the select2 filterformatter code sees an array, it thinks you are looking for two separate tags; so an exact match won't find Basically this can be solved in two ways:
I don't have that much free time, so option 2 probably won't be happening any time soon. And since I plan on releasing a new filter option called I'm not saying I won't ever update the select2 filterformatter. I just don't have the time right now. |
Hi @Mottie It's not only about the comma you're talking about. |
Ok, there was a bug in the select2 filterFormatter code in that it was not escaping special regex characters - like the parenthesis! So I've fixed that part of the select2 filterFormatter code (ref) - here is a demo. You can get a copy of the fixed code from here : https://github.com/Mottie/tablesorter/blob/working/js/jquery.tablesorter.widgets-filter-formatter-select2.js Please note that:
|
Thanks a lot for the fix. For the comma problem, i'm not able to understand whether I'll have to remove the comma from the table data or the drop down |
Hmm, I actually had to dig into the code and found that you can change the 0: function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
separator: "|",
match: true // adds "filter-match" to header
});
}, So now you don't have to worry about the commas in the table, but now you can't manually type in a comma to create a new tag. Gotta love incomplete documentation. |
By the way, you can save yourself a lot of headache/work by adding a class name to your headers: <th class="select2">AlphaNumeric</th>
<th class="select2">AlphaNumeric 2</th>
<th>Numeric</th>
<th class="select2">Animals</th>
<th>Sites</th> then instead of defining the filter_formatter: {
// target all select2 columns
'.select2' : function ($cell, indx) {
return $.tablesorter.filterFormatter.select2($cell, indx, {
separator: '|',
match: true // adds "filter-match" to header
});
}
} |
That's cool @Mottie |
Code for the Filter :
Issue is in the attached screenshot
![image](https://cloud.githubusercontent.com/assets/3133431/5784985/31dfee26-9d97-11e4-8720-cd1acbfbd4f6.png)
I tried making
match : true,
which also doesn't workThe text was updated successfully, but these errors were encountered: