Hi all,
I am getting an error message saying : “dash.exceptions.InvalidCallbackReturnValue: The callback …data-table.data…data-table.style_table… is a multi-output.
Expected the output type to be a list or tuple but got None.”
Here workplace4.get_desc will return me a dataframe with 5 column values . What I am trying to do is , when I press the button then only the the table should show up with the updated filter data what I am getting from workplace4.get_desc function.
please help me with this , Thanks
-- coding: utf-8 --
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State
import dash_table as dt
import workplace4
import pandas as pd
external_stylesheets = [‘https://codepen.io/chriddyp/pen/bWLwgP.css’]
app = dash.Dash(name, external_stylesheets=external_stylesheets)
app.layout = html.Div([
html.Div([dcc.Input(id=‘input-box’, type=‘text’, placeholder=‘Enter Jira-id’)], style={‘width’: ‘20%’, ‘display’: ‘inline-block’}),
html.Div([
dcc.RadioItems(
id=‘radio’,
options=[
{‘label’: ‘Description’, ‘value’: ‘Description’},
{‘label’: ‘Summary’, ‘value’: ‘Summary’},
{‘label’: ‘Description+Summary’, ‘value’: ‘Both’}
],
labelStyle={‘display’: ‘inline-block’})],
style={‘width’: ‘32%’, ‘display’: ‘inline-block’}),
html.Div([
html.Button('Submit', id='button')],
style={'width': '32%', 'display': 'inline-block'}),
html.Br(),
html.Br(),
html.Div(id='output-container-button',children=''),
dt.DataTable(id='data-table', columns=[
{'name': 'Jira-id', 'id': 'Key'},
{'name': 'Title', 'id': 'Summary'},
{'name': 'Description', 'id': 'Description'},
{'name': 'Status', 'id': 'Status'},
{'name': 'Resolution', 'id': 'Resolution'}
],
style_table={'overflowX': 'scroll',
'display': 'none'},
style_data={
'whiteSpace': 'normal',
'height': 'auto'
}),
dcc.Input(id='description',type='hidden'),
dcc.Input(id='summary',type='hidden'),
html.Button('Submit', id='button1' , style={'display': 'none'}),
html.Div(id='output-container-button1',children=''),
dcc.Input(id='description_search',type='hidden'),
dcc.Input(id='summary_search',type='hidden'),
html.Button('Search', id='button2', style={'display': 'none'})
])
@app.callback(
dash.dependencies.Output(‘output-container-button’, ‘children’),
#dash.dependencies.Output(‘output-container-button’, ‘children’)],
[dash.dependencies.Input(‘button’, ‘n_clicks’),dash.dependencies.Input(‘radio’, ‘value’)],
[dash.dependencies.State(‘input-box’, ‘value’)])
def update_output(n_clicks,radio,value):
if n_clicks is None:
n_clicks=0
if n_clicks > 0:
df=workplace4.get_desc(value,radio)
result = html.Div(children=[
html.Div(children=[html.H6(‘Description: ‘),dcc.Input(id=‘description’,type=‘text’,value=’"{}"’.format(df[‘Description’].values[0]),style={ ‘width’:‘600px’}),
html.H6(‘Summary: ‘),dcc.Input(id=‘summary’,type=‘text’,value=’"{}"’.format(df[‘Summary’].values[0]),style={ ‘width’:‘600px’})],className=“six columns”),
html.Div(children=[
dt.DataTable(id=‘data-table’, columns=[
{‘name’: ‘Jira-id’, ‘id’: ‘Key’},
{‘name’: ‘Title’, ‘id’: ‘Summary’},
{‘name’: ‘Description’, ‘id’: ‘Description’},
{‘name’: ‘Status’, ‘id’: ‘Status’},
{‘name’: ‘Resolution’, ‘id’: ‘Resolution’}
],
data=df.to_dict(‘records’),
editable=True,
style_table={‘overflowX’: ‘scroll’,
‘display’: ‘block’},
style_data={
‘whiteSpace’: ‘normal’,
‘height’: ‘auto’
})],className=“six columns”),
html.Button(‘Custon search’, id=‘button1’, style={‘display’: ‘block’}),
html.Div(id=‘output-container-button1’,children=’’)
],className=“row”)
return result
@app.callback(
dash.dependencies.Output(‘output-container-button1’, ‘children’),
#dash.dependencies.Output(‘output-container-button’, ‘children’)],
[dash.dependencies.Input(‘button1’, ‘n_clicks’)])
def update_output1(n_clicks):
if n_clicks is None:
n_clicks=0
if n_clicks > 0:
result = html.Div(children=[
html.Br(),
html.Div(children=[dcc.Input(id=‘description_search’,type=‘text’,placeholder=‘Enter Descripton Key words’)],className=‘three columns’),
html.Div(children=[dcc.Input(id=‘summary_search’,type=‘text’,placeholder=‘Enter Summary Key words’)],className=‘three columns’),
html.Div(children=[html.Button(‘Search’, id=‘button2’, style={‘display’: ‘block’})],className=‘three columns’)
],className=‘row’)
return result
@app.callback(
[dash.dependencies.Output(‘data-table’, ‘data’),
dash.dependencies.Output(‘data-table’, ‘style_table’)],
[dash.dependencies.Input(‘description_search’,‘value’),
dash.dependencies.Input(‘summary_search’, ‘value’),
dash.dependencies.Input(‘button2’, ‘n_clicks’)])
def update_output2(desc,summary,n_click):
print(‘DESCRIPTION:::’,desc)
print(‘DESCRIPTION:::’,summary)
print(n_click)
if n_click is None:
n_click=0
if n_click > 0:
df=workplace4.get_desc(desc,summary)
data=df.to_dict(‘records’)
style_table={‘display’: ‘block’,
‘overflowX’: ‘scroll’}
print(style_table)
#return [data,style_table]
return data,style_table
if name == ‘main’:
app.run_server(debug=True)