Athanasios Emmanouilidis Athanasios Emmanouilidis - 1 year ago 1085
jQuery Question

Datatables - Search Box outside datatable

I'm using DataTables ( and I would like my search box to be outside of the table (for example in my header div).

Is this possible ?

Answer Source

You can use the DataTables api to filter the table. So all you need is your own input field with a keyup event that triggers the filter function to DataTables. With css or jquery you can hide/remove the existing search input field. Or maybe DataTables has a setting to remove/not-include it.

Checkout the Datatables API documentation on this.



<input type="text" id="myInputTextField">


oTable = $('#myTable').DataTable();   //pay attention to capital D, which is mandatory to retrieve "api" datatables' object, as @Lionel said
$('#myInputTextField').keyup(function(){$(this).val()).draw() ;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download