...
Individual Settings within each setting list item can be retrieved and modified manually as well:
Expand |
---|
title | Not-Working due to a BugExample -- sdk ^1.0.45 |
---|
|
Code Block |
---|
| const health_header = await gb.getSetting("screens/\"Health\"/header");
console.log(health_header);
// Prints out: |
Code Block |
---|
| {
"id": 1612,
"manifestId": "screens/\"Health\"/header",
"exhibitId": 146,
"type": "TextInput",
"display": "Header",
"enabledOpMode": null,
"value": "Health",
"default": "",
"order": 1,
"touchless": null,
"listId": 67,
"items": [],
"read": true,
"write": true
} |
Code Block |
---|
| // To update the setting's value property
await gb.setSetting("screens/\"Health\"/header", "Health: System Operational Stats"); |
|
Expand |
---|
| The current method for Example -- sdk <= 1.0.44 Workaround |
|
The sdk version 1.0.45 introduced features that allowed the above example to work as shown. However, previous versions of the sdk were unable to find settings contained within settings lists without the exhibit developer implementing a workaround. If you are using sdk version 1.0.44 or lower, you must implement something similar to following workaround to manually read and write settings contained within SettingLists. The key logic for this method of retrieving and saving a SettingsList item setting is to first get its id value, as listed in the previous gb.getAllSettingLists() example, above. With this id , you can retrieve or save the Setting value through a modified command: gb.exhibit.getSetting(<setting-item-id><id>) . The following example assumes the exhibit has a single Setting List. Code Block |
---|
| const sl = await gb.getAllSettingLists();
const elems = sl[0].settinglistitems.find(setting => setting.listName.endsWith("Health")); // Pull out the SettingList item called "Health"
const elem_id = elems.items.find(s => s.manifestId.endsWith("screens/\"Health\"/header")).id; // Narrow down to the List elementsetting with the manifestId we're looking for, get it's (database) "id" value
retrieval = await gb.exhibit.getSetting(elem_id); // elem_id = 1612
console.log(retrieval);
// Prints out: |
Code Block |
---|
| {
"id": 1612,
"manifestId": "screens/\"Health\"/header",
"exhibitId": 146,
"type": "TextInput",
"display": "Header",
"enabledOpMode": null,
"value": "Health",
"default": "",
"order": 1,
"touchless": null,
"listId": 67,
"items": [],
"read": true,
"write": true
} |
You can also update the Setting value through a similar mechanism: Code Block |
---|
| // (see above JS example, lines 1-3)
await gb.exhibit.setSetting(elem_id, "Health: System Operational Stats") |
|
...