Reset the datatables on relogin

Reset the datatables on relogin

Sunil KumarSunil Kumar Posts: 17Questions: 11Answers: 0

the state of the datatable is getting retained even after user logout and logs in .I have used stateDuration=-1,but still the searched results or sorted results is not getting cleared when user logout.

$("#dataEntryFormTable").dataTable().fnDestroy();
        dataEntryFormTable = $("#dataEntryFormTable")
                .dataTable(
                        {   
                            "bProcessing" : false,
                            "bServerSide" : false,
                            "stateSave":true,
                            "stateDuration":-1,

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,598

    stateDuration set to -1 just uses sessionStorage. For this, you would want to clear the state with state.clear() when logging out.

    Alternatively, you can call that before recreating the table (you would need to destroy it after the clear and initialisation), or just remove the state information by hand, see this recent thread.

    Colin

  • Sunil KumarSunil Kumar Posts: 17Questions: 11Answers: 0

    state.clear() is clearing all the rows .i have also used fnDestroy after state.clear().
    I want to clear the search results and i want to show the data before search operation was done.

  • Sunil KumarSunil Kumar Posts: 17Questions: 11Answers: 0

    var v1=$("#dataEntryFormTable").dataTable();
    v1.fnFilter('');
    v1.fnDestroy();

    Above code solved my issue.

This discussion has been closed.