Reset search on DataTable with stateSave turned on

Reset search on DataTable with stateSave turned on

MaryDBAMaryDBA Posts: 1Questions: 1Answers: 0

Nothing I have tried works. I have tried every solution I can find on the internet, both in the DataTables forum and in Stack Exchange. I have version 1.10.15. I've tried the APIs. I've tried the solution such as is seen at https://datatables.net//forums/discussion/31375. This throws an error that search is not a function.

I have tried turning off stateSave, clearing, and turning it back on. With some solutions I can see the input text box clear for a millisecond before the value comes back. What does it take to make this thing reset?

Answers

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954

    That example should work. But you may need to change it to something like this:

    $('#myTable').DataTable()
    .search( '' )
    .columns().search( '' )
    .draw();
    

    If you are using ajax the variable table or whatever you are using is likely not containing the Datatable API when the code to clear the searches is executed.

    Kevin

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin

    This throws an error that search is not a function.

    See this FAQ.

    Allan

This discussion has been closed.