Start search not on every key-press
Start search not on every key-press
Hi,
I'm using server side processing (ajax) on my DataTables.
I've configured the #grid_filter input search.
I've noticed that on every digit, it triggers the preXhr.dt event and so the ajax request to the server.
This is of course "annoying" when I type a word such like "Mario" (i.e. 5 request on every letter).
Can I trigger it after X seconds of the last key digit? More natural as process...
What's the correct way?
Tried this: https://datatables.net/reference/option/searchDelay
But its act weird, such as "first digit", start, than wait, than seems "random"...
Replies
You can try one of the debounce solutions found on the forum. Maybe this thread will help.
Kevin
Just wow!! Looks like a charm! Only a thing to be improved mayb: ctrl+a (i.e. select all) shouldn't retrigger the ajax server, how would you take care of this?
I would look at checking for which key is pressed and not search if ctrl+a is pressed. This SO thread shows how to check which key is pressed.
Kevin