Clear button?

Clear button?

MyNicknameMyNickname Posts: 31Questions: 6Answers: 0

Is there a clear button or something else to clear all filters at once?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,743Questions: 1Answers: 10,111 Site admin
    Answer ✓

    No because DataTables provides an API to allow column filters (which I presume is what you are talking about), but it doesn't actually provide the input elements itself. So it doesn't know anything about the inputs and thus can't clear them.

    If you are using a library such as YADCF then that might have a clear all option.

    Allan

  • ScyzorScyzor Posts: 19Questions: 5Answers: 0

    I think you are looking for something like

    <div class="clear-filters">
    <button type="button" class="btn btn-primary right">Clear filters</button>
    </div>
    

    and then

            $( ".clear-filters button" ).click(function() {
                table.search( '' ).columns().search( '' ).draw();
                $('tfoot input').val('');
            });
    
This discussion has been closed.