How to store inputs
Introduction
Would you like to save your inputs? Then save configuration values in an entity data store by following these steps.
Prerequisites
- You configured the frames and routes for your solution.
- You configured the relevant contents such as the control panel(s), model(s), viewer(s) and data store.
1. Add an entity data store
In order to store multiple entities, you can configure an EntityDataStore
. Each entity has a set of properties with values.
- Add an entity data store block with
kind: EntityDataStore
. - Define the
properties
each entity contains. The properties can be of typeNumber
for quantitative values orString
for textual values.
💡 The EntityDataStore
can store entities locally during one session or persist data across sessions. To store and load data after the initial session ends, you can use the persistToStore
property.
💡 If data is persistent, the data in the entity data store will be visible to every user who has access to the solution.
The configuration should look similar to the example below:
my-entity-datastore:
kind: EntityDataStore
persistToStore: my-store-name # Optional
properties:
my-input-1:
type: Number
my-input-2:
type: Number
my-input-3:
type: String
2. Subscribe entity data store to the control panel
To save the ControlPanel
values to an entity in the EntityDataStore
:
- Subscribe the
EntityDataStore
to theControlPanel
. - Define the
frame
andsource
. - Set the
action
to be performed.update
for editing the values of an existing entity.insert
for adding a new entity with the defined values.
💡 The keys defined under properties
should match the control names set in the ControlPanel
configuration.
The configuration should look similar to the example below:
my-entity-datastore:
kind: EntityDataStore
persistToStore: my-store-name # Optional
properties:
my-input-1:
type: Number
my-input-2:
type: Number
my-input-3:
type: String
subscribe:
- kind: ControlPanel
frame: main-frame
source: my-control-panel
action: Insert
If there are 2 entities then the stored data would look similar to the example below:
- my-input-1: 1,
my-input-2: 2,
my-input-3: "My text 1",
id: 1
- my-input-1: 3,
my-input-2: 4,
my-input-3: "My text 2",
id: 2
Next steps
Display the stored inputs in an interactive table by following the Display stored inputs guide.
Configuration
See the entity data store configuration docs for more information.