search filter text applied on a single column

search filter text applied on a single column

valdezrvaldezr Posts: 49Questions: 0Answers: 0
edited May 2009 in General
how can i change the way search box has so that instead of search in all columns, only searchs on a single column but still keeps the behaviour of search on every key press.

I know this can be done with fnFilter(text, column), but how can I invoke my function to use fnFilter every time a key is pressed on the search box?

Replies

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin
    There are two ways to do this:

    1. Make your own text box on the page and don't allow DataTables to draw it's own (i.e. use sDom)
    2. Remove the event DataTables binds to the textbox it creates and then add your own event handler.

    Either way you will need to call fnFilter on each keyup event for a textbox (i.e. $('#whatever input').keyup( function () { oTable.fnFilter( this.value, 1 ); } );

    You can see an example of who number 2 might be achieved with this plug-in which binds it's own event handler to the tables input box: http://datatables.net/plug-ins#api_fnSetFilteringDelay

    Allan
This discussion has been closed.