Reputation: 163
We are using multiselect dropdown in databricks, based on the selection in the multiselect widget the query results the graphical data. Currently we can select or unselect the options one by one individually but we wanted to have a way to select and unselect all the options from widget.
Code for the multiselect widget :
dbutils.widgets.multiselect("channel", "Temp", [str(x) for x in channel])
Upvotes: 2
Views: 7364
Reputation: 223
I don't think that's possible with a multiselect widget. My only suggestion is you use some options in the widgets that are implemented with the desired behavior when you read in the values from the widget.
e.g. create the widget with addtional "All" and "None" options
channel = ["Foo", "Bar", "Temp"]
dbutils.widgets.multiselect("channel", "Temp", [str(x) for x in channel] + ["None", "All"])
One possible implementation is that when "None" is selected that overrides all other selections. when "All" is selected that overrides all other selections except "None".
out = dbutils.widgets.get("channel").split(",")
if "None" in out:
channel_out = ['']
elif "All" in out:
channel_out = channel
else:
channel_out = out
That won't look as nice as what you want in the UI, but it will give you an easy way of toggling between running for a group of channels and then either all or none.
Upvotes: 2