How to reset values in individual column searching (text inputs) at a button click
How to reset values in individual column searching (text inputs) at a button click
Newcomsas
Posts: 2Questions: 1Answers: 0
I would like to be able to reset all the values in individual column search inputs at the click on a custom 'Reset' button in the table. Could you suggest me how to obtain this behaviour ? TIA
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
columns().search()
with a blank (""
) value will clear the column search. Make sure to usedraw()
. Also you will need to clear the search inputs, Datatables doesn't do this.Kevin
Hi @Newcomsas ,
Those column server inputs aren't part of DataTables, they'll be HTML elements that you added yourself, so to clear, just use standard JS /Jquery code.
Cheers,
Colin
Here is a working code. Every other combination did not work.
I have to clear all the textboxes via Jquery and then call the draw() method for every column and the general search textbox.
I would suggest removing the
.draw()
from this:Since you are doing the draw here:
dt.search('').draw();
This might be more efficient (or at least more readable) than using the every loop:
dt.columns().search('')
Kevin