Hello,
I'm building a ComboBox that allows users to select values from a table.
The selected value is passed to a variable, which is used by the element above (blue) to generate a thumbnail link.
However, I'm facing an issue:
I can't set the ComboBox value to empty. I would like users to have the option to clear the value directly within the ComboBox.
Is it possible to add an unfilled option to the ComboBox? I’d like to avoid introducing a new button to clear the variable of the link.
After your current setvar, you can add something like ":clear". This will add another option to your combobox to clear the value. You can then do some magic in a page Execute to set another variable based on a regexreplace of that value. If you then use the variable you define on the page rather than the one in the combobox for your eventual control, it will work the way you want it to.
Execute data on the page: "Set|Variable|Screen1ToUse|[regexreplace:clear,[var:screen1],]|SetTrigger=ValueChanged"
Note I did not test this but now "Screen1ToUse" variable should always hold either empty (when clear is clicked or when the variable is not initialized) or one of the table values you selected. Note that if your table entry contains the value "clear" it will also be replaced in this situation and you might want to reword clear into "<clear>" or something else that won't occur in your table.
EDIT: Because the SetVar automatically detects table param placeholders and processes them differently than it normally would, we need some extra syntax to make sure the entries are strictly output as ':' separated values.
i.o. [param:4733/1815,301,4200], you directly want to use a table column and then use the interlace to get the right separator. e.g. [interlace:[param:4733/1815,301,4205],|,:].
Now do note that you will lose the functionality of seeing the DisplayColumn and setting the SetColumn with the dropdown. So some more syntax might needed in other places to convert one to the other.
As an alternative of course, you could implement a separate clear button, but I bet you know that already.
After your current setvar, you can add something like ":clear". This will add another option to your combobox to clear the value.
I tried implementing this, but this is where my issue lies. The only values I see are from the table; "clear" does not appear in the ComboBox.
Indeed, there is some sugar in the code for QoL implementing of table entries in a dropdown. To avoid having to use an extra placeholder to replace the separator from the param (by default '|') we just check if we have a table entry param in the SetVar. From there on we just fill the combobox with those entries. That complicates the solution a bit but I'll update my answer.
Thank you very much; this cleared things up for me! Adding the button will be the most sensible solution.