Dropdown List

Maybe I’m missing something, but for all the many nice features of the dropdown list (combobox), it appears that if you assign it a dataset that has multiple columns, it won’t use and display only the first column. I tried ignoring all columns except 0, but it doesn’t seem to like that.

Of course, I can modify the dataset to a single column, but it would be nice not to have to do that.


The dropdown list has three modes the dataset can be in:

  1. First column (Integer), Second column (String)
  2. First column (String), Second column (String)
  3. First column (String)

If we detect the first mode the integer column is hidden and the string column is displayed. When you select a row the selected value property is the integer and the selected string value is the string.

If we detect the second mode the first string column is hidden. The selected string value is the first column and the selected label is the second column.

If we detect the third mode that is the only one that is displayed. Both the selected string value and selected label properties are the same.

There is a property on the dropdown list called “Dropdown Display Mode”. You can switch it from list to table in which case you can display any number of columns you want. The “Hide Table Columns” property is a comma separated string of columns you want to hide from the table mode. Besides the columns we expect from above you can bring back any number of columns after the first two which can be displayed in the table mode. Here is some more information on the dropdown list:


Thanks, Travis. I had pretty much worked through all of that.

What I wanted to do was hand the dropdown list the system.db.getConnections() function return and display/select only the first column of that dataset. Somehow with all of its options, it seems it can’t do that directly.

The problem is that the system.db.getConnections function returns a dataset where the first two columns are strings. So the dropdown list thinks it is in the second mode (String and String). With that mode the first column get hidden no matter what you do. However, we can use a little bit of scripting to fix this issue.

First add a dynamic property to the dropdown called ds that is a dataset. Bind the property to the following expression:runScript("system.db.getConnections()", 5000)Next, add the following script to the propertyChange event of the dropdown list:[code]if event.propertyName == “ds”:
header = [“idx”, “Name”, “Description”, “Status”]
newData = []

data = system.dataset.toPyDataSet(event.newValue)
idx = 0
for row in data:
	newData.append([idx, row["Name"], row["Description"], row["Status"]])

event.source.data = system.dataset.toDataSet(header, newData)[/code]Put the dropdown in table mode and it should work just fine.