http://www.datatables.net/plug-ins/api/fnFilterClear

http://www.datatables.net/plug-ins/api/fnFilterClear

cachiapcachiap Posts: 40Questions: 5Answers: 0
edited October 2015 in DataTables 1.10

Hi Allan,

I have read up on this new API and it's great but I'm having a problem as it does not seem to clear the information in the individual column filter fields. It clears the global search and redraws the table just fine but if I do a column search it only redraws the table leaving any previous search info in the column search fields. Do you have any suggestions on what might be happening?

I think I remember seeing a comment somewhere on this site where you had previously indicated that clearing the column fields was not possible because DataTables didn't know anything about what was displayed to the end user in these boxes. Is that true with this new API? The header at the top of the page claims "Remove all column and global filters applied to a table".

I'm using this with a button "ClearSearch" (id='reload') so the function is called when the button is "clicked".

       ```$(document).ready(function() {

           $('#reload').click(function(){


        var table = $('#ClientInventoryJoin').dataTable();

        table.fnFilterClear();

        draw();

            });


          .........................
          ..........................

        });```

Thanks for clarifying this for me.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    edited October 2015 Answer ✓

    it does not seem to clear the information in the individual column filter fields

    As in the input elements? DataTables has no knowledge of whatever input element is being used to perform the column filter - it just acts on the API commands to perform a filter. You would need to clear them yourself if that is what is required.

    Allan

  • cachiapcachiap Posts: 40Questions: 5Answers: 0

    Thanks. I see I have more work to do.

    Cheers

  • cachiapcachiap Posts: 40Questions: 5Answers: 0
    edited October 2015

    Allan,

    I fixed my problem with a little javascript that simply reloads my table and clears all entries in the search fields (both the column fields and the global search). If any one is interested here is the script

    function reload() { location.reload(true); }

    the function reload() is called when a Clear Search button is clicked.

    Regards,

    Paul

This discussion has been closed.