Clear items from dropdown via scripting?

Is there a way to clear or delete items (options) from the dropdown control?

Using scripting, I need a way to clear the dropdown, then repopulate it but can’t see a way to remove or clear an existing list?

There is. The easiest way is probably through a binding (maybe including a transform), but that isn’t strictly through scripting.

Through pure scripting, the pattern would be

  1. Acquire the data in the options property of the dropdown.
  2. Manipulate the data (adding and dropping items as desired).
  3. Set the options property of dropdown to the newly manipulated data.

According to a very quick and not at all comprehensive investigation, you can use these methods on the options data to accomplish step 2:
‘append’, ‘count’, ‘extend’, ‘index’, ‘insert’, ‘isSequenceType’, ‘pop’, ‘remove’, ‘sequenceType’

Hello, can you point me to where you found that information? I couldn’t find it in the manual.
Thks.

This gives you the structure of the dropdown properties: Perspective - Dropdown - Ignition User Manual 8.1 - Ignition Documentation

This talks about bindings in Perspective: Bindings in Perspective - Ignition User Manual 8.1 - Ignition Documentation

This talks about transforms in Perspective: Transforms - Ignition User Manual 8.1 - Ignition Documentation

The scripting knowledge is scattered throughout and is general knowledge from hacking various things together, I guess. Any online python tutorial should give you at least an idea of how to use append, extend, etc.

2 Likes