Perspective dropdown schema

I have a dropdown menu that is utilizing a query to populate what should be in the dropdown list based on the user logged in. The dropdown properties make it seem like I could have a third, fourth, fifth column that would be selected when I select something from the dropdown, but I’m having trouble implementing that.

I have the value and label, but then also want to have an area value populated based on the item selected. Which I know I could just write a script to populate the area based on the value selected, but it makes it seem like I could just pull that column from the query also and have the action of selecting something in the dropdown also populate the selected area since it says the minimum is value and label. Am I totally misreading this?


You can have additional keys for each Dropdown option, but the dropdown will only display the label key and assign the value key to the same dropdown option.

The additional keys are only useful when doing scripting, a la

self.getSibling('Label').props.text = self.props.options[self.props.value].my_key

That’s unfortunate for what I was trying to do, but thanks for the quick response.

If you’d like to more clearly describe your intended use-case, I might be able to suggest an alternative avenue.

I have a query that currently returns an [m x 2] dataset that I then transform into a qualifying series of {value, label} for the dropdown to use, but I have realized that I could actually get more information [m x n] set if I could bring more columns in and then when I select the label it would then set the correlated material to a selected set that I could do a lot with. I know I can take the values and go back out and run another query to recapture all of the data that I need. It just seemed that letting the dropdown selection target all of it for me would be simpler.

If you bind Dropdown.props.options to your [m x n] query and transform it into an array of dictionaries (much like you’ve already done, but including keys for any other properties you need from the query)

[{"label":"One", "value":1,"area":"Bay7"},{"label":"Zero", "value":0,"area":"Bay19"},{"label":"Two", "value":2,"area":"Bay5"}]

Then you could also make a custom property on the Dropdown. Bind this new custom property to Dropdown.props.value, and supply the following Script transform:

return self.props.options[value].area

This would allow you to only run the query once, while still having a property which provides the value you need based on the selected value.

1 Like

For the record, I found that this is drastically easier if you turn value into an object with multiple keys.

Ie. [{“label”:“One”, “value”:{“value”:1, area":“Bay7”}},{“label”:“Zero”, “value”:{“value”:0,“area”:“Bay19”}},{“label”:“Two”, “value”:{“value”:2,“area”:“Bay5”}}]

That way the value is now the items which are more easily target-able from change value scripts and what not. It also allows for duplicating the label within the value property if you for some reason needed that information more easily.

1 Like