Searching only on the previous search set
Searching only on the previous search set
My current function (below) searches based on the data returned from right-clicking a cell. The problem is the search results are always based on ALL the data. I'm trying to get it to continue to drill down using only data from the previously applied search.
$('#sr_table tbody').on( 'mousedown', 'td', function (e) {
if( e.button == 2 ) {
searchData = table.cell(this).data();
table.search( searchData).draw();
}
} );
I have also tried to use table.columns({search:'applied', order:'applied'}).search( searchData).draw();
, but that produces no results every time.
This question has an accepted answers - jump to answer
Answers
You are basically replacing the previous search when you call the
search()
method with a value. What you would need to do is get the current search term (which you can do with that same method) and then append the additional search term.Allan
Thanks for the idea. To implement it, I ended up having to do some less than ideal manipulations on the array to get it to work. For some reason when I just put the raw array into search() |DT, it wasn't working correctly.
var searchTerms = [];
$('#sr_table tbody').on( 'mousedown', 'td', function (e) {
if( e.button == 2 ) {