How to reset bStateSave cookie?

How to reset bStateSave cookie?

int14int14 Posts: 8Questions: 3Answers: 0

We have a problem regarding bStateSave cookie. We have used bStateSave=true. The feature is working fine.
It remembers the state even after the user logs out of the application. So the next time when user again log in to the application, the settings are still there.

Is there have any way to clear the setting at the time of logout?

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @int14 ,

    Yep, just call state.clear(),

    Cheers,

    Colin

  • int14int14 Posts: 8Questions: 3Answers: 0

    Hi @colin,
    I have tried using the below mentioned ways.
    1. $('#RFPDetailsGridDataTable').state.clear(); < RFPDetailsGridDataTable is my table name>
    2. table.state.clear();

    in my layout page but it is not working.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    state.clear() works here:
    http://live.datatables.net/qejamizu/1/edit

    To diagnose your issue please provide a link to your page or a test case replicating the issue.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • int14int14 Posts: 8Questions: 3Answers: 0

    Hi @kthorngren,
    my project is in development phase so I will not be able to provide you the link. I am explaining you the issue which I am facing.
    In my dashboard there is a datatable where "bStateSave": True, and according to the setting everything is working fine. But If I search any thing from search textbox
    The box retain that value until I manually delete that value. even if I log out from the application and then login in that case the box retain the same value.

    Please let me know if this helps.

    I am working on a MVC(Asp.net) application.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Then you will want to use stateSaveParams to adjust how the parameters are saved. The docs have an example of what you are looking for. Plus I updated the test case so you can see it in action:
    http://live.datatables.net/qejamizu/2/edit

    Kevin

  • int14int14 Posts: 8Questions: 3Answers: 0

    One more thing I am not clearing the state using button I have to clear the state from my another(layout page).
    So, How I can call the table.state.clear();

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    The example I provided is clearing the state. Try these steps:

    • Sort by the Position column (or any besides name)
    • Click the "Run with JS" button or reload the page, the sort should be by the Position column
    • Click the "Clear State Save" button
    • Click the "Run with JS" button or reload the page, the sort should be the default of Name (column 0)

    If this is not working on your page then please update my example to replicate your issue.

    Kevin

This discussion has been closed.