Force Drop Down List to show the first option

When using a parameterized drop down list, what is the best way to force it to show the first option by default?

If I save the view, it will load with that option, but if I change the options, it defaults to “Select…” when what I would like it to do is just default to its first option.

I’m pretty sure someone will suggest some scripting to address this, which is helpful. But what I want to know is if there is a default parameter on the component to do this.

It starts like this

But when changing the area, it doesn’t default to the first option



If the dropdown’s value is null or empty then the placeholder is used. There is no first party way for making it use the “first” option.

You need to insure that the value is always set to an option.

I handle this by adding a change event to the value property either using the provided value or a default value.

self.props.value = next((opt.value for opt in self.props.options if opt.value == currentValue.value),self.props.options[0].value)

This does have the effect of making the value strict (must be included in the optoins list), which may or may not be desired for your application.

If you don’t want it to be strict then you would need to do something like this:

if not currentValue.value:
    self.props.value = self.props.options[0].value

This will also not work if you need multSelect

@lrose thanks for this. Here is what ended up working. What happens is that the new options will bind properly but the actual value does not update. So the tag change script has to be on the options because if they are on the value, and it doesn’t change, the script never fires…

Script is on the options

Value Change Script Content

	options = [opt.value for opt in currentValue.value]
	if self.props.value not in options:
		self.props.value = self.props.options[0].value