searchDelay after last character

searchDelay after last character

ctmlctml Posts: 26Questions: 9Answers: 0

Is it possible to include an option/flag to change the behaviour of searchDelay to reset the timer after each character press so that it uses the time after the last character was entered? I found a few threads related to this

https://datatables.net/forums/discussion/comment/72144/#Comment_72144

I think it'd be a much better UX if it waited until they finished typing, especially for large tables where we want to avoid unnecessary redraws.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948

    See if this thread about creating a debounce for the search input will do what you want.

    Kevin

  • ctmlctml Posts: 26Questions: 9Answers: 0

    Thanks @kthorngren , I feel a bit stupid because none of those code snippets work. They all have reference to _ which I don't have, is this part of a library I need to include with datatables? I am not using serverside like the folks mention in that thread if it matters.

    Uncaught ReferenceError: _ is not defined
        at debounceSearch
    
  • kthorngrenkthorngren Posts: 21,322Questions: 26Answers: 4,948
    Answer ✓

    As noted in the thread this requires the use of underscore.js. Here is a working example with underscore.js and the firt code snippet with a 1000 to show it works.
    http://live.datatables.net/pedoqoqi/1/edit

    Kevin

Sign In or Register to comment.