delay between typing and searching?

delay between typing and searching?

mihomesmihomes Posts: 165Questions: 23Answers: 0

Is there any way to specify a delay time between search words typed and when it is actually searched? I'd like to add a delay in there so it is not searched so quickly (every keystroke), but rather once someone is (probably) done typing their search.

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    There is in 1.10.3 :-). Check out searchDelay.

    Allan

  • mihomesmihomes Posts: 165Questions: 23Answers: 0

    Perfect! I need to start paying more attention to the changes you add in on these versions :)

  • mihomesmihomes Posts: 165Questions: 23Answers: 0

    Thought it wasn't working then loaded the latest to be sure and it does. You must have just added this as I am pretty sure I had 1.10.3 to begin with :)

  • mihomesmihomes Posts: 165Questions: 23Answers: 0

    One thing I would add on this... it appears this setting applies to the first keystroke only rather than resetting if another keystroke has been made within the set time.

    An easy way to test this :

    searchDelay: 1000

    Hold down any key in the search box. Once you hold down a key it will search every second even though you have never let up on the key. I expected this to only search once after I was done typing (1 second after my last key was entered).

    I think most people would assume the same.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin

    Someone did in this thread as well. Oddly, no one ever brought this up when it was the default for server-side processing, but twice in one day now :-).

    The intention of the throttle is that it is still responsive, to so get the feel of quick updates, but and throttle how often the server is hit.

    Allan

  • mihomesmihomes Posts: 165Questions: 23Answers: 0
    edited October 2014

    To be honest I was doing some work with a jquery plugin called select2 for form inputs. You can populate the drop down list, search, paginate, etc through ajax where I am querying my db to display the results. They have a similar feature built in for user searches, however, it delays action until 'x' ms after the last key pressed. By default it works exactly how datatables does now. I found it much more user friendly, to me at least, where the delay occurs in this manner. Not everyone types very fast and it certainly saves a lot of hits/queries on the db that are unnecessary.

    Using that plugin is what prompted my original question if datatables had the same ability or not as I wanted to do the same with its search feature.

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    It is an option I might add in future. I would encourage anyone else who reads this thread and wants this feature to post here as well.

    Allan

  • all4truthall4truth Posts: 2Questions: 0Answers: 0

    Hello Allan, I would think that after the last key stroke would provide the best and most expected user response. Not sure what that entails, but along with this request, accept my thanks for a GREAT!!! software application.

  • AndreiAndrei Posts: 1Questions: 0Answers: 0

    Hi Allan and all,
    I do agree with mihomes - delay, applied after the last keystroke does feel more logical.
    Please do add this feature. I recall that the legacy plugin fnSetFilteringDelay did exactly that.

    I have been using DataTables for a couple of years now and really love it. I am currently in a process of upgrading to the 1.10.5, and have noticed this behavior:
    search delay is applied to every search except the first. if I set searhDelay to say 1000, and type food, I get the first request sent immediately with the sSearch : f, succeeding requests are delayed according to searchDelay setting. Is this a bug?

    For now I just hacked the core searchFn function with this:

    if (val.length == 1) return false;
    

    Also, when i type quite quickly the word "specification", I would expect for search to fire after I stopped typing and not every second : s,spec,specific,specificat,specification.
    Just my two cents.
    Thanks again for this excellent piece of software!

This discussion has been closed.