Search results

State Persistence in ASP.NET Core Tree Grid control

22 Jul 2021 / 1 minute to read

State persistence refers to the TreeGrid’s state maintained in the browser’s localStorage even if the browser is refreshed or if you move to the next page within the browser. State persistence stores treegrid’s model object in the local storage when the enablePersistence is defined as true.

Get or set localStorage value

If the enablePersistence property is set to true, the treegrid property value is saved in the window.localStorage for reference. You can get/set the localStorage value by using the getItem/setItem method in the window.localStorage.

Copied to clipboard
//get the TreeGrid model.
var value = window.localStorage.getItem('treegridTreeGrid'); //"treegridTreeGrid" is component name + component id.
var model = JSON.parse(model);
Copied to clipboard
//set the TreeGrid model.
window.localStorage.setItem('treegridTreeGrid', JSON.stringify(model)); //"treegridTreeGrid" is component name + component id.