Clear column search and then search again
Clear column search and then search again
karlie
Posts: 83Questions: 17Answers: 0
Hi I have a column search from a button which works
// Sold Out Search
$('#sold_out').click(function () {
table
.columns( '.sold_out' )
.search( 'YES' )
.draw();
} );
What I would like to do would be to combine clearing the table and then searching. In the example above if the table has had other column searches applied and none of those are sold out, it will just return no results on click (which I would expect) I guess I would want to combine Destroy and Column Search in one; table gets destroyed and then the search applied
Hope that makes sense!
This discussion has been closed.
Answers
Do you want to destroy the table to clear the other column searches or do you want to load different data?
If you just want to clear the column searches you can search those columns with something like
columns().search("")
.Kevin
I want to load different data, but once the table has been filtered by the original column search it won't load the different data as it hasn't been pulled in by server side. That's why I was thinking the best way would be to destroy the table then search with the new search term. I can destroy the table, and I can perform a column search, I just can't work out how to combine them, if that makes sense!
If I column search for all 'Orange' products for instance, and then column search for all 'Sold Out' Products it will only return Orange Sold Out products. I would like to redraw the whole table then search for Sold Out all in one button click/function.
will do that.
It will clear the existing search term for all columns and then apply the search
YES
to the.sold_out
column(s).Allan
Thanks Allan, I tried that exact code before posting in here, but think my JS was cached in the browser, and it didn't work. I cleared the cache and this works now!