I have a problem with the following code where the dropdwon doesn show the selected item after I click on the items. I get some items from SQL Db and it shows on the DropDown items, however, when I click on this items they dont appear as the value of the DropDown . Can anyone help me find the problem there.
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State, Event
import Query
app = dash.Dash()
colors = {
‘background’: ‘#7FDBFF’,
‘text’: ‘1111111’
}
obj=Query.CI()
app.layout = html.Div([
html.H1(style={‘backgroundColor’: colors[‘background’]},children=“test”),
html.Div( style={
'textAlign': 'center',
'color': colors['text']
},children='''
List of industries:
'''),
html.Label('Enter nmi or industry name'),
dcc.Input(id='my-id'),
dcc.Dropdown(id='comp-id', multi=False),
html.Button('Submit!', id='my-button'),
html.Div(id='my-div')
])
@app.callback(
Output(component_id=‘comp-id’, component_property=‘options’),
[Input(‘my-button’, ‘n_clicks’)],
state=[State(component_id=‘my-id’, component_property=‘value’)]
)
def update_output_div(n_clicks, input_value):
data = obj.get_companies_nmi(input_value)
return [{‘label’: i, ‘value’: i} for i in data]
@app.callback(
Output(component_id=‘my-div’, component_property=‘children’),
[Input(‘comp-id’, ‘value’)]
)
def update_output_div(input_value):
return str(input_value)
if name == ‘main’:
app.run_server(host= ‘0.0.0.0’,debug = False)