Search results

Get or Set Local Storage Value in React Grid component

28 Nov 2022 / 1 minute to read

If the enablePersistence property is set to true, the grid 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 Grid model
     * "gridGrid" is component name + component id
     */
    const value: string = window.localStorage.getItem('gridGrid');
    const model: object = JSON.parse(value);
Copied to clipboard
  /** set the Grid model
   * "gridGrid" is component name + component id
   */
  window.localStorage.setItem('gridGrid', JSON.stringify(model));