Skip to content
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

Filter not working when multiple filters have the same values #1363

Closed
MitoG opened this issue Feb 24, 2017 · 3 comments
Closed

Filter not working when multiple filters have the same values #1363

MitoG opened this issue Feb 24, 2017 · 3 comments

Comments

@MitoG
Copy link

MitoG commented Feb 24, 2017

Hello,

while working with the tablesorter.widget.filter.js I came accross a situation where the table would not be filtered when the filter was changed.

Example:

Type Priority
Foo Low
Bar Medium
FooBar High

In this example each row is assigned a value 0 | 1 | 2 so Foo and Low would both be assigned the value 0

Type Priority Value (for both columns)
Foo Low 0
Bar Medium 1
FooBar High 2

Now if you were to set the Type filter to Foo intern the variable combinedFilters would contain the value 0 since it's a joined array of all filter values.
This happens twice actually:
widget-filter.js Line: 886: combinedFilters = ( filters || [] ).join( '' );
widget-filter.js Line: 1314: combinedFilters = ( filters || [] ).join( '' );

After filtering, the value of combinedFilters will be written into c.lastCombinedFilter
widget-filter.js Line: 1502: c.lastCombinedFilter = combinedFilters;

If the next filter you set would also be of the value 0 the code would check if the values of the newly written combinedFilters would equal the value of c.lastCombinedFilter

widget-filter.js Line: 910-912:

if ( c.lastCombinedFilter === combinedFilters && filter !== false ) 
{
    return;
}

Now both variables would be 0 so the code returns without filtering the table by the new filter.

Solution:

In my project I changed the line 886: and 1314: to
combinedFilters = ( filters || [] ).join( ',' );

As I don't know if there is a better way to solve this I have not submitted a pull-request, I'll leave this to the people who know javascript.

@Mottie
Copy link
Owner

Mottie commented Feb 25, 2017 via email

@Mottie
Copy link
Owner

Mottie commented Mar 28, 2017

Ok, sorry it's taken me so long to get around to this issue. This problem has been fixed in the master branch (demo). I plan on pushing a new release very soon.

@Mottie
Copy link
Owner

Mottie commented Apr 2, 2017

Version 2.28.6 is now available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants