search box send query on every keypress

search box send query on every keypress

kaekae Posts: 2Questions: 0Answers: 0
edited August 2009 in Bug reports
I have a database with over 2 million entries in it, of cities and variants of their spellings.

when I type, say, "monaghan", datatables sends a search query for every key press.

I'm a fast typist, and am finished typing the word well before the first result comes back.

there is a race condition here, though, as a search for "mon" will sometimes be finished well after before a search for "monaghan", so when those results come back, the table will be updated with the results of a search for "mon" instead of "monaghan".

a solution here is to delay the search query until a reasonable time (say, 300ms) has gone after the last keypress.

Replies

  • allanallan Posts: 63,368Questions: 1Answers: 10,449 Site admin
    Hi kae,

    2 million records - good going :-)

    Fully agree - you don't want to DDOS your own server with DataTables(!!!) and that's what the fnSetFilteringDelay plug-in is for: http://datatables.net/plug-ins#api_fnSetFilteringDelay . It does exactly what you describe (well almost - the default is 250mS rather than 300mS - but that is customisable ;-) ).

    Regards,
    Allan
  • kaekae Posts: 2Questions: 0Answers: 0
    thanks man, I guess I should read the fine manual in future!
This discussion has been closed.