Filters get cached in the Datatable

Filters get cached in the Datatable

Mauro26Mauro26 Posts: 17Questions: 7Answers: 0
edited October 2020 in Free community support

Hi guys,
I'm having a problem, everytime I make a search and then I reload the page the field is empty but the filtering is still there.

I'm having 5 results out of 900 after refreshing the page and having all the filter fields empty.

This is the filter

Order No

    $('#ID_textcontrol6A61BBF2')
.on( 'keyup', function () {
                var val = $(this).val();
                table.fnFilter($(this).val(), table.api().column('docNumber:name').index());
            } );

and this is what I'm trying to use to reset the filters after the refresh of the whole page.

$.fn.dataTable.ext.search = [];
table.fnFilter('');

But it doesn't work.
It shows "Showing 0 to 0 entries out of 12"

Answers

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    Do you have stateSave enabled?

    Kevin

  • Mauro26Mauro26 Posts: 17Questions: 7Answers: 0

    Hi Kevin,
    Yes I have it in true, it could be that?

    Regards.

  • kthorngrenkthorngren Posts: 21,330Questions: 26Answers: 4,951

    According to the stateSave docs:

    When enabled aDataTables will store state information such as pagination position, display length, filtering and sorting.

    You can use stateSaveParams to remove the items you don''d want saved. Looks like you are doing a column search so you could reset all those to '""'. Use the browser's debugger or console log to investigate the contents of thedata` parameter to see what you need to do to clear the column searches.

    Kevin

This discussion has been closed.