Hello everyone!
Basically, I have a dropdown widget, and at some point I want to change the options available, but still maintain the same selected option.
The problems that I find are:
- If I want to delete the widget and create a new one, it seems like the object was not deleted and the "index" of the selected value stayed.
- the dbutils.widgets.dropdown receive a defaultValue, not the selected value. (is there a function to assign the value?)
- When I change the list of options with dbutils.widgets.dropdown, I end up viewing (displayed widget), and getting (dbutils.widgets.get()) different values.
I'm attaching some code that contains said problem.
😄 , help?
if not("val" in locals()):
dbutils.widgets.dropdown("A", "4",["1","2","3","4","5","6","7"], "text")
val=dbutils.widgets.get("A")
if (val=="5"):
dbutils.widgets.remove("A")
dbutils.widgets.dropdown("A", "4",["1","3","4","5","6","7"], "text")
print(dbutils.widgets.get("A"))
if (val=="3"):
dbutils.widgets.remove("A")
dbutils.widgets.dropdown("A", "4",["1","2","3","4","5","6","7"], "text")
print(dbutils.widgets.get("A"))