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

How to clear search button in datatables 1.9?


Asked by Kimberly Reeves on Dec 02, 2021 FAQ



One way would be to change the input type of the filter to "search" - then HTML5 browsers will automatically show a clear widget. However, you'd have to press return after clicking it, so I wanted a one-click solution. Here's what I came up with. It works with DataTables 1.9.
In this manner,
You could clear the search in a very simple way: var table = $ ('#example').DataTable (); table .search ( '' ) .columns ().search ( '' ) .draw (); Share. Improve this answer. edited Feb 10 '16 at 17:09. AaronS.
Also Know, 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.
And,
I wanted a generic way to add a "clear filter" button to the text filter on all the DataTables on a site. One way would be to change the input type of the filter to "search" - then HTML5 browsers will automatically show a clear widget. However, you'd have to press return after clicking it, so I wanted a one-click solution.
Moreover,
Normally DataTables will initialise sequentially and there will be no need for this function,... Check if a TABLE node is a DataTable table already or not. Check to see if a row is 'open' or not. This function will place a new row directly after a row which is currently on display on the page, with the HTML contents that is passed...