How do I Refresh a table
How do I Refresh a table
nisdis
Posts: 1Questions: 1Answers: 0
Hi, I wuld like to know how to refresh a table once a search has been made using .column.search()
Can I clear search using code or clear state of the table ?
This discussion has been closed.
Answers
Call
draw()
.As the documentation for
column().search()
notes:Allan
I am trying to create a Clear Search button, too, but I am doing something wrong even after reading that documentation and searching the forums for help. Is there an example code page that shows a sample implementation with a Clear Search button that clears the global dataTables search field? If I could look at some working code in a fiddle or something, I could figure out what I am doing wrong. Thanks!
All you should need to do is
table.search('').draw();
.Allan
Thanks! I found this example with a wider search: http://jsfiddle.net/4rvmtv7d/
My problem was that I forgot the single ticks inside the search() function. But I also have 2 other drop-down filters and two range filters, and I have found that I need to use table.columns('').search('').draw() to get the table to reset properly after using the other filters, plus just a table.search('').draw() to reset the table after using the global smart search box. Somehow I think this isn't how it should need to work? I'll have to take a look at my other code to see if I've created some weird dependency, but if you have any insight about this, it would be much appreciated.
Thanks again for your hard work and great plugin!
It sounds correct to me.
search()
is the global search andcolumns().search()
is the column search. If you are using both and want to clear both, then, yes, you would need to clear both.Allan