setProperty - Setzen des Wertes einer Variable
Beispiel
In dem folgenden simplen Beispiel wird die Verwendung von setProperty gezeigt. Praktisch kann man diese Funktion unter anderem dazu zu verwenden zwischen verschiedenen Seiten eines Formulars zu springen, wie hier gezeigt.
setProperty.json
{
"$schema": "http://bpc.virtimo.net/forms/1/schema",
"metaData": {
"id": 0,
"version": 0
},
"components": [
{
"type": "container",
"label": "setProperty Example",
"components": [
{
"type": "html",
"value": "'<p>Current value of variable: ' + /data/someValue + '</p> New value of variable after click on subtract: ' + (/data/someValue - /data/subtractValue)"
},
{
"type": "numberfield",
"label": "Changeable value of variable",
"value": "/data/someValue"
},
{
"type": "numberfield",
"label": "Input value which is subtracted from above variable if subtract button is clicked",
"value": "/data/subtractValue"
},
{
"type": "button",
"label": "Increment",
"action": "setProperty",
"target": "/data/someValue",
"value": "/data/someValue +1"
},
{
"type": "button",
"label": "Subtract",
"action": "setProperty",
"target": "/data/someValue",
"value": "/data/someValue - /data/subtractValue"
},
{
"type": "button",
"label": "Set to 1",
"action": "setProperty",
"target": "/data/someValue",
"value": 1
}
]
}
],
"configuration": {
},
"state": {
"data": {
"someValue": 5,
"subtractValue": 3,
"readOnlyVariable": true
}
}
}
Eingebettete Vorschau
Keywords: