I have an application that is a multi user application. One of the pages has a dropdown that is multi-select. I store data with the user as part of the key. I only want the user that owns the data to be able to change it. I want other users to be able to view it. I do not see a good way to do this. Obviously I could make a callback that immediately undoes any changes in the dropdown that a read only user makes but it would be much nicer to just make it read only.
Hello @Brent,
Do you have any code snippet available to give some representation of how you are building the dropdowns?
By read only, you mean that the user cant add/remove options or select it in general?
dbc.Col(dcc.Dropdown(id=‘best-versions-dd’,
options=version_options,
value=version_values,
multi=True), width={‘size’: 3})
By read only I mean that the user can see all of the options and the values but they cannot add or remove any value.
Can they make selections on it?
no, when it is in read only mode no selections can be made
You can build your page’s layout to use a function:
def dropdowns(user=None):
layout = []
if user == '1':
layout.append(dcc.Dropdown(id='user1Drop', multi=True))
else:
layout.append(dcc.Dropdown(id='user1Drop', disabled=True, multi=True))
if user == '2':
layout.append(dcc.Dropdown(id='user2Drop', multi=True))
else:
layout.append(dcc.Dropdown(id='user2Drop', disabled=True, multi=True))
if user == '3':
layout.append(dcc.Dropdown(id='user3Drop', multi=True))
else:
layout.append(dcc.Dropdown(id='user3Drop', disabled=True, multi=True))
return layout
Something along these lines, obviously you would do whatever with the function to populate your dropdowns, you could pass selected values as well.