how to reset the filters in a datatable
To reset custom filters
If you're using custom filtering function as in this example, you need to clear controls involved before filtering and redrawing the table.
$('input.search_events').val('');
$('#todays_table').dataTable().fnDraw();
To reset global search
jQuery DataTables 1.9+
Call
fnFilter()
API method with empty string as a first argument to reset the global search and redraw the table.For example:
$('#example').dataTable().fnFilter('');
jQuery DataTables 1.10
Call
search()
API method with empty string as a first argument followed by call todraw()
API method to reset the global search and redraw the table.For example:
$('#example').DataTable().search('').draw();
For those who's performing a search with column and regex:
$('#example').DataTable().column('').search('').draw();
DataTables 1.10+ new API can achieve the same effect without the requirement for plug-ins using the following chaining:
var table = $('#example').DataTable();
table.search('').columns().search('').draw();
If you are using earlier versions of DataTables, you need to include plugin library called fnFilterClear and call:
var table = $('#example').DataTable();
table.fnFilterClear();
Please see this DataTables API page for more information and the plugin that needs to be used for earlier versions of DataTable.