I have a Dropdown menu that has to values, an id and the name. I would like the Name to be the selection and when selected that text is passed to a label. Is there a way to get the dropdown to give back a value AND text for other elements on the page to just take the text. I am using the value for other elements on the page.
Ignition 8.1 Maker on Ubuntu 22.04
A Dropdown option
can be given any number of keys, but all it cares about for functional purposes is label
and value
.
If these id
and name
entries are coming in from a binding, I recommend using a transform in order to help the Dropdown. The following script will make each option of the Dropdown display the "name" of the entry, and that value will also be used as the value
of the Dropdown.
# this is the transform script
options = []
for entry in value:
selection = entry["name"] # maybe "Name", depending on the binding
# note that both label and value are the same value because it sounds like you ONLY care about the name
options.append("label": selection, "value": selection)
return options
With this in place, you only need to bind the Labels you mentioned to Dropdown.props.value
.