AutoSuggest search

AutoSuggest search

David1981David1981 Posts: 6Questions: 0Answers: 0
edited April 2009 in General
Hello People,
Is it difficult to make the searchbox autosuggest ?
kind regards!

to the developers: amazing work!!!

David

Replies

  • allanallan Posts: 63,236Questions: 1Answers: 10,418 Site admin
    Hi David,

    Quite a nice idea using auto suggest on the filter box. This is a library I've had success with before (for other projects): http://www.pengoworks.com/workshop/jquery/autocomplete.htm

    Basically what you will need to do is provide it will a callback function which will suggest the completion based on your data in the table. This could be done by parsing through the data stored in DataTables, or through some Ajax request.

    Hope this helps,
    Allan
  • David1981David1981 Posts: 6Questions: 0Answers: 0
    Hello,

    Can You take a look at the following:

    the "id" of my datatable = "records".
    I followed your suggestion to implement the autosuggest that you provided me. I think the id of the filter input text = (name of datatable)+"_filter" so i did the following:

    $(document).ready(function() {
    $("#records_filter").autocompleteArray(
    [
    "test","testing","tester","tes"
    ],
    {
    delay:10,
    minChars:1,
    matchSubset:1,
    onItemSelect:selectItem,
    onFindValue:findValue,
    autoFill:true,
    maxItemsToShow:10
    }
    );
    });

    What am i doing wrong ?

    Greetings and thx for your help in advance.

    David
  • allanallan Posts: 63,236Questions: 1Answers: 10,418 Site admin
    Looks pretty good - just two small things:

    1. The ID isn't on the INPUT element, it's on the div wrapper. So your selector should be:
    $("#records_filter input").autocompleteArray(

    2. Make sure this runs after the DataTables initialisation.

    I've just tired that and with works nicely.

    Allan
This discussion has been closed.