cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

Notebook dropdown widget

Sagar1
New Contributor III

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Kaniz
Community Manager
Community Manager

Hi @sagar Varma​ ,

This link has a step-by-step description. Please go through it and share your amazing idea. Here you go !

View solution in original post

7 REPLIES 7

Kaniz
Community Manager
Community Manager

Hi @sagar Varma​ ,

Please read these docs:-

Hopefully they'll help you or else you can always come back with a NO !

Sagar1
New Contributor III

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.​

Kaniz
Community Manager
Community Manager

Nice observation @sagar Varma​ !

Would you like to raise a request on our Ideas portal?

Sagar1
New Contributor III

Yes, @Kaniz Fatma​  I would like to raise a request on ideas portal.​

Kaniz
Community Manager
Community Manager

Hi @sagar Varma​ ,

This link has a step-by-step description. Please go through it and share your amazing idea. Here you go !

Kaniz
Community Manager
Community Manager

Hi @sagar Varma​ , Just a friendly follow-up. Do you still need help, or were you able to raise a request on the ideas portal? Please let us know.

nic_paul24
New Contributor II

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)

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.