Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How to reset the filters in a jquery datatable?


Asked by Antonio Jones on Dec 06, 2021 jQuery



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. 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.
Moreover,
I am using the jQuery plugin DataTables ( http://datatables.net) for pagination, search capabilities and filtering. There is a filter function ( http://datatables.net/release-datatables/examples/api/multi_filter_select.html) that places form select elements for each column.
Additionally, Please note that this method does not reset 'select inputs' (https://datatables.net/examples/api/multi_filter_select.html) to their default value. This is correct - to explain why: DataTables doesn't know anything about the input elements themselves since it is just the API method that are being called with values.
In respect to this,
DataTables then read the data to be displayed in each column using the column index. jQuery DataTable is a highly customizable and feature-rich library that can be used to enhance the normal HTML tables.
In this manner,
Use jQuery to filter/search for specific elements. Type something in the input field to search the table for first names, last names or emails: Example explained: We use jQuery to loop through each table rows to check if there are any text values that matches the value of the input field.