Minimum number of characters in search field

Minimum number of characters in search field

bjo3rnbjo3rn Posts: 2Questions: 0Answers: 0
edited December 2011 in General
Hi,

I am looking for a smart solution to configure the search field in a way that a request is not triggered until a certain number of characters have been filled in to reduce the server load. I assume this can be accomplished with one of the callback functions but I can't figure it out.

Thanks in advance for a hint and a huge thank you to the author of datatables for this awsome piece of code.

Best regards,
Bjoern

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    Hi Bjoern,

    I knew when I posted this comment earlier I had forgotten one form of manipulation for the filtering input: http://datatables.net/forums/discussion/7580/button-search#Item_2 :-)

    Basically what you need to do (either wrapped up in an API plug-in, which would be nice!, or otherwise) is to unbind the keyup event that DataTables uses by default for the filtering input, and then bind your own that will call fnFilter when the length of the input is >=3 (or whatever).

    The filter on return plug-in ( http://datatables.net/plug-ins/api#fnFilterOnReturn ) shows a nice way of doing the majority of that.

    Allan
  • bjo3rnbjo3rn Posts: 2Questions: 0Answers: 0
    edited December 2011
    Ah, nice. Thanks a lot. There is so much more to discover in the Plugin-Api functions. Should have taken a look into them earlier.
This discussion has been closed.