Dataset Filtering on Dropdowns

I am using a memory tag data set to reference options in a dropdown on my perspective app. I want to have a second dropdown that references all options that have the same attribute based on the first dropdowns selection.

Example: Dataset -

Colorado, Denver
Colorado, Grand Junction
Nevada, Las Vegas
California, L.A.
Virginia, Lexington

If in the first dropdown selection I choose “Colorado”, I want the second dropdown to display options “Denver” and “Grand Junction”.

I currently have this code in the second dropdown:

tabList = []
for row in range(value.getRowCount()):
return tabList

You need to actually loop through the data set. This code will add the same value for however many rows are in the value dataset.

Something more like

tabList = []

selectedValue = self.getSibling("Zone_Select_Drop").props.value

for row in range(value.getRowCount()):
    if value.getValueAt(row, 0) == selectedValue:
        tabList.append(value.getValueAt(row, 1)

return tabList

That of course can be compressed to a comprehension, but it should get you close.

Why am I getting an Error on the return?

tooltip saying “no viable alternative at input ‘return’”

Check your indentation. It needs to all be either tabs or spaces, and it needs to be at the correct level.

I can see from the screen shot that it looks incorrect. Copy and paste can often mess around with it.

De-dent lines 14 and 15 one step each.

Nailed it. Thanks guys!