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_searchDelay not working v2.27.8 and how to limit minimum characters #1299

Closed
andrewpros opened this issue Oct 6, 2016 · 23 comments
Closed

Comments

@andrewpros
Copy link

andrewpros commented Oct 6, 2016

As in the title

I set it but it is always instant, external, column filters, all the same.

Example http://jsfiddle.net/9tBgZ/115/

Any help @Mottie, i know it was an issue some time ago, but supposedly it was fixed, but this is the same example it was posted then.

The other issue is i don't see a way to set minimum characters to start searching.

@walmartshopper
Copy link

Just ran into the same problem in v2.27.7, going to try a patch

@walmartshopper
Copy link

The problem seems to be line 3996-3998 of jquery.tablesorter.combined.js:

wo.filter_searchTimer = setTimeout( function() { tsf.checkFilters( table, filter, skipFirst ); }, liveSearch ? wo.filter_searchDelay : 10);

So if liveSearch is true, it sets the timeout to the search delay and if liveSearch is false it sets it to 10ms. I believe it should be the opposite. If liveSearch is true, it should be 10ms and if liveSearch is false it should be set to filter_searchDelay. I swapped the 2 and it's working for me.

@andrewpros
Copy link
Author

andrewpros commented Oct 8, 2016

I don't think so, i want live search, if it is true (default one) it should let me set the delay.

So this code looks good, i really don't see where is the problem.

I wanted to check also if any another input character is resetting the delay from start, but due to this error, i can't check it.

@TheSin-
Copy link
Collaborator

TheSin- commented Oct 8, 2016

I'm going to try and look into this tomorrow guys, just been busy rebuilding my system the last 2 days. and today is turkey dinner so I can't miss that ;)

@andrewpros andrewpros changed the title filter_searchDelay not working v2.27.8 filter_searchDelay not working v2.27.8 and how to limit minimum characters Oct 10, 2016
@andrewpros
Copy link
Author

I updated the question to also know how to limit the minimum characters to search.

@walmartshopper
Copy link

Thanks for looking into it. I guess I was confused on the terms used. I was thinking "live search" meant that it would search instantly as you typed, and that turning on a search delay implied you were disabling live search. But reading the docs again I can see it's still considered live search even with the delay.

So I guess my solution doesn't really solve the problem, but it does make it work the way I want it to. It seems in the line liveSearch ? wo.filter_searchDelay : 10 );, liveSearch was always false even when filter_liveSearch was set to true, so it was always using a delay of 10ms instead of the search delay. So after swapping them, now it always uses the delay.

@andrewpros
Copy link
Author

andrewpros commented Oct 10, 2016

Well, then looks like there is a problem that liveSearch is always false.

I have found that this line

liveSearch = wo.filter_liveSearch.fallback || false;
is the problem, not sure why.

if ( typeof liveSearch !== 'undefined' ) {
                    liveSearch = wo.filter_liveSearch.fallback || false;
}

Before it it is true, but after it is false. And it is the same in bind keyup function.

Now it is still not working even if i set it hard-coded to true.

It still immediately calls tsf.checkFilters and this follows to tsf.findRows which is the main filtering one, as soon as i press just one character it calls it all and it slows as hell, freezes for a sec.

This is the main reason i need it, i have more than 1000 rows and filtering has a lag, every character input immediately repeats the lag cuz delay is not working and no way to set minimum search characters still with delay.

I need this to work ASAP.

@Mottie
Copy link
Owner

Mottie commented Nov 4, 2016

HI everyone! Sorry for the long delay in responding. I've been away on a much needed extended vacation.

I believe the problem is the same as the issue described in #1152. In v2.27.7, a listener for the "input" event was added to solve issue #1280. And because "input" is fired after each change to the input value, it bypasses the live search setting.

I think the best solution might be to not include the "input" event listener unless a mobile browser is detected. I don't like to use browser sniffing, but it might be the best solution in this case.

@andrewpros
Copy link
Author

Well it still don't work, the best solution is the library actually to work as it should, i see no reason this can't work in the best possible way then there are many rows, desktop cpu are also not so fast.

So filter_searchDelay should work
Minimum characters should be added

This way it won't try to search anything every time i enter next letter if it is lower than say 3, just make it stop do anything if it is not x characters, and after it is say 3 chars the filter_searchDelay kicks in, preventing it to start search too soon and thus making it LAGGY or even freeze the browser.

Now for every key input it starts the search and if there is lots of rows it overlaps the calls = lag/freeze, this needs to be fixed.

I have tested it and if the delay would work as intended there is a single call and it is quite faster.

@JamoCA
Copy link

JamoCA commented Nov 22, 2016

I've configured filter_searchDelay:2000. I can type a 9 letter word in less than 1 second, but 8-9 separate ajax queries are being immediately performed for each keystroke instead of debouncing and waiting 800ms between key events. (I think this bug was added in v2.27.4.) I was using v2.27.5 when I encountered this and hoped upgrading to v2.27.8 would fix it. I'm worried that my backend's server security will rate limit or identify this as a DDOS attack if enough users filter the tables at the same time.

If this isn't going to be fix soon-ish, is there a temporary workaround?

@Mottie
Copy link
Owner

Mottie commented Nov 22, 2016

Hi @JamoCA!

Yes, sorry, I did find a fix for this issue, but I have not had a chance to thoroughly test it.

I will go ahead and push it to the master branch. But I don't want to push a patch until I can resolve the issue with Edge (see #1303). I would appreciate it if you would let me know if any issues arise with the fix.

@Mottie
Copy link
Owner

Mottie commented Nov 27, 2016

This should now be fixed in v2.28.0!

@andrewpros
Copy link
Author

andrewpros commented Nov 28, 2016

@Mottie

filter_searchDelay is still not working, example is the same as in the first comment, delay is 5 sec, but no delay at all, so why it is closed but not tested at all?

@Mottie
Copy link
Owner

Mottie commented Nov 28, 2016

Hey @andrewpros!

Sorry, I was in a rush to get the pager fix out. I thought this was related to the liveSearch option. Sorry about that! I'll examine this issue again.

@Mottie Mottie reopened this Nov 28, 2016
@Mottie
Copy link
Owner

Mottie commented Nov 28, 2016

As for setting a limit on the minimum number of characters, set it in the filter_liveSearch option (demo)

$('table').tablesorter({
    usNumberFormat: false,
    widgets: ['zebra', 'filter'],
    widgetOptions: {
        filter_liveSearch: 5, // start searching after 5 characters have been entered
        filter_searchDelay: 5000
    }
});

@Mottie
Copy link
Owner

Mottie commented Nov 28, 2016

DOH, not fixed yet... still working on it.

@Mottie
Copy link
Owner

Mottie commented Nov 28, 2016

Ok, now it should be all fixed. Please try these two demos:

The fix is in the master branch. A minor patch update has not yet been planned, but I won't wait too long.

@andrewpros
Copy link
Author

@Mottie

Nice, now it's working thx.

There is one problem only, if i input minimum number of characters and then backspace it, it won't return to default set, stays filtered as it was when minimum characters provided.

There should be some check if min chars are set and we delete at least one or more it should disable the filter and show initial full list again.

@Mottie
Copy link
Owner

Mottie commented Dec 13, 2016

Hi @andrewpros! I have made an attempt at show the full list after pressing backspace, but when the full table is shown, the filters are cleared... I'll need to find a different solution once I switch focus back to this repo.

@andrewpros
Copy link
Author

@Mottie I don't get it, this is the point, to disable filters when we are below min chars if min chars was set.

@Mottie
Copy link
Owner

Mottie commented Dec 13, 2016

Yes, I know... I was telling you that I am still working on it.

@andrewpros
Copy link
Author

@Mottie Well as we see it was not clear enough for me :-)

@devnuhl
Copy link

devnuhl commented May 4, 2017

These changes are all in v2.28 as far as I can tell, but I'm still suffering from the delay not working. Have set the delay to 1000ms+ and still it seems to fire after the second character no matter what.

UPDATE: I set filter_liveSearch to false, and filter-selects now required hitting enter to filter the results, however, I moved over to the field I was having problems with triggering after two (of three) characters and a 1000ms delay, and it is still triggering on two characters being entered, despite the delay and liveSearch being false.

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

6 participants