window.localStorage.clear(); is slower than vue grid when exiting the page with enablePersistence true

Hi

When a user logs out from my application, he goes back to the login page.
When the login page loads, I added window.localStorage.clear(); in order to remove all grids related persistence.
The problem is, when I logout from the grid page itself, the localstorage is deleted but is immediately filled again with the grid persistence.

I read that the persistence is stored when leaving the page so it seems that my clearing code happens before even though it happens after the "next" page finishes to load. I couldn't find a place where my code will happen after yours. Is there such place? Happens on both chrome and firefox.
Thanks

3 Replies

RR Rajapandi Ravi Syncfusion Team May 22, 2020 12:02 PM UTC

Hi Amos, 

Greetings from syncfusion support 

Based on your query we suspect that you want to clear the grid’s persisted data from local storage while logging out the page. You can achieve this requirement by destroying the grid after disabling the enablePersistence property and clearing the local storage data. This is demonstrated in the below code snippet 
 
// Button click function 
function OnClick() {   //place this code in your logging out function 
            var gridObj = document.getElementById("Grid").ej2_instances[0]; 
            gridObj.enablePersistence = false;    
            window.localStorage.setItem("gridGrid", ""); 
            gridObj.destroy(); 
            location.reload(); 
} 

Regards,R
Rajapandi R



AM Amos May 22, 2020 10:22 PM UTC

Thanks, worked.


RR Rajapandi Ravi Syncfusion Team May 25, 2020 03:12 AM UTC

Hi Amos, 

We are happy to hear that your issue resolved. 

Please get back to us if you need further assistance. 

Regards, 
Rajapandi R 


Loader.
Up arrow icon