Notebook dropdown widget
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ03-18-2022 04:57 AM
I have created a dropdown (say B) in my notebook whose input depend on dropdown( say B). So if select some value in dropdown A, it corresponding value appears in B dropdown & i'm selecting one amongst it. Now if i change the value in dropdown A, then Value in drop B is also changing but the one previously selected is still there. Is there any way if i cab refresh that dropdown.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ03-22-2022 09:09 AM
Hi @Kaniz Fatmaโ ,
โ
I tried and explored all the documents before raising question here, but none of them has solution for my problem. There after i relaize that like remove widget we must have reset widget option as well, which will reset it to its default value, as we are providing it during its creation.โ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ03-22-2022 10:28 AM
Yes, @Kaniz Fatmaโ I would like to raise a request on ideas portal.โ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ03-16-2023 06:06 AM
If the previously selected value of B is not meant to be in the list of values for newly selected dropdown A value, then you could set a default value (ie: 'No selection') that the B dropdown should have when first created. In a method to define how you create B, check if current B value is not valid for A, if it is not then create the dropdown widget with the default value.
If the value of B makes sense also when dropdown A changes, try to find a way to figure out if A changed. For example write the code to create B in a cell where you also call dbutils.widgets.get(A). This will run the cell when A changes, then create B with the default value. When running the cell that checks if A changed, also write create_B (input_values, 'No selection').
It's complicated, but follow the logic and you will get there.
def create_B (input_values, default):
values = [value for value in input_values]
if (default not in values):
default = 'No selection'
if ('No selection' not in values):
values.insert(0, 'No selection')
dbutils.widgets.dropdown('widget B', default, values)

