Dropdown List Binding

I’m having trouble binding a tag in a Dropdown list. It seems to work backwards…
When I bind a tag {PartSelected} to the ‘Selected String Value’, it does not write the selected value to the tag its binded to. In other words, I select a value of ‘7’ from Dropdown, that value is in the ‘Selected String Value’, but it does not make it to the {PartSelected} tag that I bind to that value. However, if I modify the value of the {PartSelected} tag, it updates the Dropdown list. This seems backwards, the goal here is to use a dropdown list to fill a tag with the value selected. I even tried writing a property change script, but it does the same thing.

1 Like

On your binding make sure you tick the ‘Bidirectional’ option. This allows the Dropdown List to write its value back to the tag. Note that updating the value of the tag directly will still update the List - I don’t think it’s possible to stop this.

Did you check “bidirectional” when you created the binding? That’s almost certainly what you are looking for.

Thanks for the responses, that was it. :thumb_left:

I am trying to create a Dropdown in Perspective setting 3 states( 0-Off,1-Slow,2-Fast) with main goal ,every time I select a label from the dropdown change the integer on the PLC code. Ive started with binding the Tag on the PLC on the params as a “value”. Then on the actual component(dropdown) I have named the labels for every value under options, and the values are binded to the (params/value) from the actual window. It doesnt seem to be working despites I am only being able to read the tag when I change it from the PLC. Any ideas would be much appreciated.

The following component worked for me. It is bi-directionally bound to a tag.
Check that your binding is bi-directional (and saved).
Check that you have read-write enabled (Project > Comm Read/Write).
If those requirements are in place, check the logs on the Gateway to see what could be preventing the write.

[
  {
    "type": "ia.input.dropdown",
    "version": 0,
    "props": {
      "options": [
        {
          "value": 0,
          "label": "Off"
        },
        {
          "value": 1,
          "label": "Slow"
        },
        {
          "value": 2,
          "label": "Fast"
        }
      ]
    },
    "meta": {
      "name": "Dropdown"
    },
    "position": {
      "height": 36,
      "width": 256,
      "x": 273,
      "y": 133
    },
    "custom": {},
    "propConfig": {
      "props.value": {
        "binding": {
          "type": "tag",
          "config": {
            "mode": "direct",
            "tagPath": "[default]Experimentation/IntRepl",
            "bidirectional": true,
            "fallbackDelay": 2.5
          }
        }
      }
    }
  }
]

Thank you very much for your script is much appreciated. As I am very new with python and scripting, may I ask where shall I include this? Also it gives me a syntax error on line 1 which doesn’t make sense atm.

What I supplied was not Python, it was a JSON object which defines a Dropdown in Perspective. You should be able to copy what I supplied to your clipboard and then paste it directly into your View. Once the Dropdown is in place, you will want to replace the tag path in the binding with your tag path.

When you initially paste the Dropdown, you’ll see a warning in the Property Editor on the Dropdown.props.value property, which is due to the fact that my tag path doesn’t exist in your project.