Initialize search input in jQuery Datatables
The proper way is now:
var table = $( '#mytable' ).DataTable();
table.search( 'initial search value' ).draw();
So the proper way of doing this is using the oSearch parameter.
https://datatables.net/docs/DataTables/1.9.0/DataTable.defaults.oSearch.html
$(document).ready( function() {
$('#example').dataTable( {
"oSearch": {"sSearch": "Initial search"}
} );
} )
You can trigger an event manually with .trigger()
:
$('#example_filter label input[type=text]')
.val('Default Product')
.trigger($.Event("keypress", { keyCode: 13 }));
Depending on your code, you may want "keyup"
instead.