How to reset/clear selections from a specific searchpane filter manually using jQuery Datatables
How to reset/clear selections from a specific searchpane filter manually using jQuery Datatables
ShaliniSinghal.26
Posts: 4Questions: 1Answers: 0
I want to clear selection from a specific searchpane filters created using jQuery datatable manually using code. How to acheive this.
I'm aware that to clear all selections we use : $('#example').DataTable().searchPanes.clearSelections()
but not sure if i want to clear a single filter's selections.
Answers
Using standard jQuery, you could click the 'x' button
Please see example here,
Colin
jQuery('.dtsp-searchPane').each(function (index, elemnt) {
if (index > 0) {
const selectedClearButton = jQuery(elemnt).find('.clearButton');
selectedClearButton.click();
}
});
I want to reset all the filters together except the 1st one using above code. but I observed only first filter gets reset, others remains as it is.
Please assist how to manually reset the filters as many as we want.
I observed that if I set the property viewTotal of searchpanes to false then the reset multiple search panes using for loop is working correctly.
but, If we set viewTotal to true, then only first searchpanes reset is working and others remain as they are.
Please suggest with an approach where irrespective of viewTotal value, we can reset multiple search panes in loop.