How to filter with the search text box after press enter key?
How to filter with the search text box after press enter key?
Hi Allan,
First of all, congratulations for your plugin, has been really useful for me !.
I'm working with a web service for the server side processing and it gives me every time the result of manage differents databases so...i wonder if there is any chance to change the input text box filter to search only after press the enter key. I've been trying to change the original code, (c.keyup and c.keypress), for this issue but it never works ! Has anyone got it? Could you give me some clue how to get it?
Regards,
Pawel.
First of all, congratulations for your plugin, has been really useful for me !.
I'm working with a web service for the server side processing and it gives me every time the result of manage differents databases so...i wonder if there is any chance to change the input text box filter to search only after press the enter key. I've been trying to change the original code, (c.keyup and c.keypress), for this issue but it never works ! Has anyone got it? Could you give me some clue how to get it?
Regards,
Pawel.
This discussion has been closed.
Replies
Allan
Thanks for replying. I guess that u mean something like this ?
$("thead input").keyup( function () {
if (this.value == 13)
oTable.fnFilter( Vals.value ) );
else
Vals += this.value;
} );
I haven't tried this code yet but my question is....how to set this functionallity to the default search text box?
Regards,
Pawel.
[code]
$("div.dataTables_filter input").keyup( function (e) {
if (e.keyCode == 13) {
oTable.fnFilter( this.value ) );
}
} );
[/code]
What you want to do is unbind the event handler DataTables adds ( http://api.jquery.com/unbind/ ) and then attach your own with the code above. That will then act as a filter with the return key.
Allan
Thanks for your time Allan and congratulations again for your work,
Cheers,
Pawel.
It was really simple to change, here is the code
[code]
$(document).ready(function() {
var oTable = $('#test').dataTable( {
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
"bAutoWidth": true } );
$('#test_filter input').unbind();
$('#test_filter input').bind('keyup', function(e) {
if(e.keyCode == 13) {
oTable.fnFilter(this.value);
}
});
} );
[/code]
Thanks for your time, hope it helps !
Regards,
Pawel.
Hi Allan,
A little stumped, how is this done with the 1.10 build?
Trying to figure out an alternative to oTable.fnFilter(this.value);
What's wrong with using
fnFilter
? The old API is still present and can still be used. Or you can use the new API'ssearch()
method. (remember also how to access the new API).Allan