We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to disable persistence from JavaScript?

Thread ID:





148167 Oct 8,2019 08:47 PM UTC Oct 9,2019 12:28 PM UTC ASP.NET Core - EJ 2 1
Tags: DataGrid
Asked On October 8, 2019 08:47 PM UTC

How can I disable persistence in grid (or other control) from JavaScript?
I have a button with onclick event, in which I want to disable persistence and refresh page.
My current code:
function btnClick()
location.rel='nofollow' href = "/Card/List";
I clear localstorage for grid control, but after page reload localstorage is set again (because grid control set persistence data in unload event).
So maybe I need to disable persistence in grid control before page reload. But how?
I tried:
var ej2Obj = document.getElementById('MyGrid').ej2_instances[0];
ej2Obj.persistence = false;
(also ej2Obj.enablePersistence = false;)
but it didn't work.

Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On October 9, 2019 12:28 PM UTC

Hi Adgr, 
Based on your query, we can understand that you wish to clear the Grid’s persisted data from local storage while refreshing the page through button click event. 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() { 
            var gridObj = document.getElementById("Grid").ej2_instances[0]; 
            gridObj.enablePersistence = false; 
            window.localStorage.setItem("gridGrid", ""); 
We have prepared a sample based on this for your reference. You can find it below, 
Seeni Sakthi Kumar S 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon