Category / Section
How to clear persisted data in grid on page reload
1 min read
It is possible to clear the Grid’s persisted data from local storage while refreshing the page programmatically. This can be achieved by disabling the enablePersistence property, clearing the local storage and then destroying the grid using destroy method.
This is demonstrated with button click event in the below code snippet,
// Button click function
function OnClick() {
var gridObj = document.getElementById("Grid").ej2_instances[0];
gridObj.enablePersistence = false;
// Clear grid’s local storage data
window.localStorage.setItem("gridGrid", "");
// Destroy the grid
gridObj.destroy();
// Page reload
location.reload();
}
Output

JavaScript (ES5) sample - https://stackblitz.com/edit/jqmn1z-zffbyc
TypeScript sample - https://stackblitz.com/edit/cemjls-hf9wne
ASP.NET Core sample - https://www.syncfusion.com/downloads/support/forum/148167/ze/Persistence32707892