Is it possible to clear the basic keyword search field when the SearchPane clear button is clicked?
Is it possible to clear the basic keyword search field when the SearchPane clear button is clicked?
Hi,
I've been integrating with DataTables for a client, and we all love it. However, they've asked if the Clear button from the SearchPane extension can be made to clear the default Search by Keyword input.
I can't find a way to add second event to the button via the API.
So the route I think I need to take is to add a custom "Clear" button, which clears all search panes and empties the active search.
How would I code the button action to reset the Keyword and SearchPane selections both?
Handler
So far this is what I tried, and it didn't truly reset the search.
buttons: [
{
text: 'Clear',
action: function (e, dt, node, config) {
dt.search('');
}
}
],
This question has an accepted answers - jump to answer
Answers
You need to add
draw()
, for example:You can right click and inspect the SearchPanes
Clear All
button to find the selector to use, something like this example:https://live.datatables.net/ximesucu/1/edit
Kevin
Thank you Kevin, that works perfectly for this use-case.