I am unable to clear the filters using the fnFilter().
Here is my HTML code :
<table id="todays _table>
<thead>
<tr id="todays_search_input_feilds">
<td class="input_filter">
<input type="text" id="type" class="form-control search_events">
</td>
<td class="input_filter">
<input type="text" id="vendor " class="form-control search_events">
</td>
</tr>
</thead>
</table>
And Here is my JQuery Code
$('#todays_table').dataTable().fnFilter('');
oTable.fnClearTable();
I tried clearing using the following approach:
$('input[class="form-control search_events"]').val('');
But the problem with this is that, it is clearing the value but the data is not loading in the dataTable. It is loading only after i click on any of the filters
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 to draw()
API method to reset the global search and redraw the table.
For example:
$('#example').DataTable().search('').draw();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With