Start search after 3 characters been typed OR a button clicked

Start search after 3 characters been typed OR a button clicked

afarberafarber Posts: 53Questions: 0Answers: 0
edited April 2011 in General
Hello,

is there please an option to start the search only after 3 characters have been typed in?

I have written a PHP-script for colleagues displaying 20,000 entries and they complain that when typing a word, the first few letters cause everything to freeze (using latest Chrome browser on Windows XP).

I've searched in the forum, haven't found a solution yet.

An laternative would be to have the search to be started by a button clicked and not by the character typing.

Thank you
Alex

Below is my current code:

[code]
$("#my_table").dataTable( {
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bAutoWidth": false,
"aoColumns": [
/* qdatetime */ { "bSearchable": false },
/* id */ null,
/* name */ null,
/* category */ null,
/* appsversion */ null,
/* osversion */ null,
/* details */ { "bVisible": false },
/* devinfo */ { "bVisible": false, "bSortable": false }
],
"oLanguage": {
"sProcessing": "Wait please...",
"sZeroRecords": "No ids found.",
"sInfo": "Ids from _START_ to _END_ of _TOTAL_ total",
"sInfoEmpty": "Ids from 0 to 0 of 0 total",
"sInfoFiltered": "(filtered from _MAX_ total)",
"sInfoPostFix": "",
"sSearch": "Search:",
"sUrl": "",
"oPaginate": {
"sFirst": "<<",
"sLast": ">>",
"sNext": ">",
"sPrevious": "<"
},
"sLengthMenu": 'Display ' +
'10' +
'20' +
'50' +
'100' +
'all' +
' ids'
}
} );
[/code]

Replies

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    There are a couple of options - all involving fnFilter ( http://datatables.net/api#fnFilter ). The first way is to simply unbind the keypress handler DataTables puts on the element and add your own which calls fnFilter when there are enough characters. Another is to have your own filtering box with fnFilter attached to a click on a button next to the input.

    You might find Visual Event useful to see how DataTables does it itself: http://sprymedia.co.uk/article/Visual+Event

    Allan
This discussion has been closed.