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.26ShaliniSinghal.26 Posts: 2Questions: 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

  • colincolin Posts: 14,303Questions: 1Answers: 2,431

    Using standard jQuery, you could click the 'x' button

     $('.dtsp-searchPane:eq(1) .clearButton').click();
    

    Please see example here,

    Colin

  • ShaliniSinghal.26ShaliniSinghal.26 Posts: 2Questions: 1Answers: 0
    edited June 23

    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.

Sign In or Register to comment.