Local Storage

Block Group: Browser API
Icon: Local Storage block icon

Allows your project to store information in the user’s browser, over multiple sessions and browser windows. To store multiple key-value pairs, use multiple blocks.


Input/Output Properties

These properties can take input and give output.

key sets or returns the key for a key-value pair.

global specifies whether this block sets and returns the global or non-global value for the key.

value sets or returns the value for a key-value pair.


Model

The user's selection of the Weekly option for a chart's roll-up type is bound to the Local Storage block's value property. This choice is remembered if the user opens a new window or starts a new session.

Local Storage dataflow model


Use Case

This section covers how to pass a value into a Local Storage block using JavaScript.

Changes to value from JavaScript do not take effect if the JavaScript is in the developer console for the same Solution Builder frame. Changes take effect only if the JavaScript is in an IFrame, or a different .dg5 file from the Local Storage block.

To pass a value into a Local Storage block:

  1. Create a Local Storage block and define the global and key properties.
  2. Save user input with Local Storage block.
  3. Use the following syntax to append code to define the value: window.localStorage['dg:project:key1'] = "value1";

Settings: