Vision-Dropdown Component-Searchable Dropdown

Hello, how can we make vision dropdown searchable within its data. and Is it any way to open dropdown by clicking on another component textbox?

Hello Omii,

The dropdown component in Vision can be searchable within its data. You can check under Properties>Selection Mode and change it to Editable in order to do it.

https://docs.inductiveautomation.com/display/DOC81/Vision+-+Dropdown+List#VisionDropdownList-Properties

A few recent posts that may be helpful,

Here is another post that could be useful for people searching for this functionality:
Search Through Dropdown Component with Keystrokes

Direct link to the exchange resource:

Justin,

Regarding this searchable dropbox (which is totally cool, BTW), what mods need to be made to allow multiple columns to be displayed even though we're searching only on one column?

The reason I ask is that I have a table with non-distinct values in a column but the desired record is based on info in one of the other columns. Without being able to see those other values, the user is blindly selecting non-distinct values.

That's an interesting question; I haven't developed a table mode for that. In reality, it isn't a JComboBox at all; it's just a simple text field with an associated popup menu, so anything's possible. When I get some time, I'll look into it, and if I come up with something, I'll post it here.

I've developed a working prototype with a table mode if you want to test drive it:

As it's programmed right now, it automatically sets the column widths to width of the longest text up to the maximum table width property. After that, it proportionally narrows the widths, so they fit.

Edit: Made a few changes to streamline edge scenarios that were discovered during testing. The current version of the searchable dropdown that features a table mode has now been approved and is live on the exchange:
Searchable Dropdown v.3.00

1 Like

That works perfectly. Thanks!

I'll dig through it to see if there are any other enhancements that can be made.

Do you have an explanation of the different bits in the searchable dropdown component from the exchange? I am trying to use it for the first time, and I'm having trouble with two things.

  1. I need to make the selection via script sometimes, and it doesn't work the way I thought. I've tried writing to both selectedValue and selectedStringValue (the values are integers). It doesn't show the label value on the window.

  2. When I clear the selectedValue (change to -1), the selection doesn't clear from the window.

I've tried changing the bits but I haven't found a combination that works.

In the designer, if you hover the mouse over a custom property, the tool tip text will reveal the scripting name, datatype, and a description of what the property does:
image

Alternatively, I've included detailed descriptions of each property in the custom property editor:
image

I

Hmmm. I would have expected it to as well. I'll have to look into this, and get back with you.

The component usually tries to find an exact label match in the selectedLabel dataset as the text changes, and if it finds one, it updates all of the other selected properties accordingly. However, it also has propertyChange logic that will attempt to do the same thing if one of the selected properties is changed via script or expression. To ensure that circular references do not occur, each event will set an internal write in progress bit that suppresses the other event handlers until a complete update has occurred.

A few behavioral notes that could help you troubleshoot the problem:
• The selectedValue property is numeric, and the selectedValue is always taken from the first column in the dataset, but the dropdown does not force any column to be any particular datatype.
• If there is only one column, and it is not a numeric datatype, the dropdown will substitute the selected index as the selected value
• Also, if there is only one column, regardless of datatype, the dropdown will cast whatever is in the column to a unicode string for use in the selected label properties
• If there is more than one column, the dropdown will always use the second column for the selected label properties regardless of how many columns there are in the dataset

Note: The column that is used for the label properties will be the text that is displayed and selectable from the dropdown, and when typing a label into the text field, the first match from top to bottom will automatically become the selected label unless a different label in the dropdown is arrowed to or clicked on.

It is possible to exploit the top to bottom automatic selection behavior via scripting by writing the desired label directly to the embedded text field in the template.
Example:

# relative path to the searchable dropdown
searchableDropdown = self.parent.getComponent('searchableDropdown')

# get the embedded textfield component from the searchable dropdown
textfield = next((component for component in searchableDropdown.loadedTemplate.components if component.name == 'textfield'), None)

# set the text property to the desired label
textfield.text = 'desiredLabel'

I'm using a standard lookup table for the dataset for the dropdown (ID, text). I can reset the selectedValue to -1 from a button, but the text doesn't go back to the unselected text until I click on the dropdown again.

Digging through the source code, I see that I used -1 for the selected value when there are no exact matches to the text in the dropdown's text field to mimic the javax swing dropdown behavior, but I didn't put anything in the code to prevent -1 from being a legit selected value for a given label. In that regard, I can imagine that there would be cases for having negative associated values, so I'm not sure it would be appropriate to treat -1 explicitly as no selection when externally written, but if a written value doesn't match anything in the dropdown's dataset, then I don't see any reason why the value shouldn't be treated as no selection.

Attached is a test version of the dropdown with my interpretation of your suggested update. It treats nonMatching values as no selection, and triggers the timer that causes the no selection text to appear. I also refactored a portion of the event logic that I felt could have been written better. If it works out for you, and if I can't get it to mess up when I have time to conduct further testing, I'll submit this revision to the exchange.

searchable_dropdown.3.0.2.zip (27.5 KB)