I'm using a plugin that I built for datatable for dropdown filter and I'm using fnFilter for it.
The issue is when I search first let's say I searched for 'test' it returns one row then when I filter, the filter doesn't do the filtering on the one row I have on the table but instead it clears my global search somehow.
Can someone please help me with this?
I think it just fnFilter clears search() on datatable but I don't want to change fnFilter to search.
I don't have that problem when applying the filter to a column, if you don't provide the column to set the filter to the value passed to the filter will replace the search.
$(document).ready(function() {
const dt = $('#example').dataTable({"sPaginationType": "full_numbers"});
$("#filterbtn").on("click",x=>{
dt.fnFilter( 'Gecko',0 );//column will not replace search
dt.fnFilter( 'Camino',1 );//multiple filters are possible
});
$("#resetfilterbtn").on("click",x=>{
dt.fnFilter( '',0 );//reset the filter (does not reset search)
dt.fnFilter( '',1 );
});
});
Here is a jsfiddle example .
In the jsfiddle example search for 3+
and get 5 rows, then press filter button and get 1 row, then press reset filter button and get 5 rows again.
If you press filter button you'll get 2 rows, no matter what you search you will not get more than 2 rows (search does not reset the filter)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.