01-23-2018 02:37 - edited 01-23-2018 06:50
01-23-2018 02:37 - edited 01-23-2018 06:50
Hello, i have a probably very simple problem. I just want to select a specific value from a array:
Settings:
<Select
label={`Battery`}
settingsKey="battery"
options={[
{name:"pos01"},
{name:"pos02"},
{name:"pos03"}
]}
/>
In app:
if (evt.data.key === "battery" && evt.data.newValue) {
let myBatteryPos = util.stripQuotes(evt.data.newValue);
console.log(myBatteryPos);
}
console:
{selected:[0],values:[{name:pos01}]}
But i need only the value:
pos01
or pos2 or pos3
can someone help me. Many Thanks
Answered! Go to the Best Answer.
Best Answer01-31-2018 02:30
01-31-2018 02:30
Old:
let myBatteryPos = util.stripQuotes(evt.data.newValue);
New:
let myBatteryPos = JSON.parse(evt.data.newValue).values[0].name;
is working.
01-31-2018 02:30
01-31-2018 02:30
Old:
let myBatteryPos = util.stripQuotes(evt.data.newValue);
New:
let myBatteryPos = JSON.parse(evt.data.newValue).values[0].name;
is working.