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)