# Chained callbacks not working

**URL:** <https://community.plotly.com/t/chained-callbacks-not-working/39051>\
**Category:** Dash Python\
**Created:** [May 7, 2020, 12:21pm UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051 "2020-05-07T12:21:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rs\_201381](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@rs\_201381](https://community.plotly.com/u/rs_201381)\
**Post date:** [May 7, 2020, 12:21pm UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051/1 "2020-05-07T12:21:23Z")

</div>

Hi,

I am trying to register 3 callbacks in my app.

Below are their signatures:

1. @app.callback(  
[Output(‘table-dropdown’,‘data’),  
Output(‘table-dropdown’,‘selected\_rows’),  
Output(‘alert-div’,‘children’),  
Output(‘refresh-div’,‘hidden’)],  
[Input(‘submit-button’,‘n\_clicks’)],  
[State(‘table-dropdown’, ‘selected\_rows’),  
State(‘table-dropdown’, ‘data’)])  
def update\_datatable(n\_clicks, selected\_rows, data):

2. @app.callback(  
Output(‘textarea-example’,‘value’),  
[Input(‘table-dropdown’, ‘selected\_rows’)],  
[State(‘table-dropdown’, ‘data’)])  
def update\_email(selected\_rows ,data):

3. @app.callback(  
Output(‘table-dropdown’, ‘selected\_rows’),  
[Input(‘table-dropdown’, ‘active\_cell’)],  
[State(‘table-dropdown’, ‘selected\_rows’)])  
def update\_selection(active\_cell, selected\_rows):

The problem is that my app works fine when I use only first 2 callbacks and NOTHING works when I add the third callback. What is the reason for this ?  
Sorry if it is a very trivial query, I have just started using dash.

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [May 7, 2020, 2:45pm UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051/2 "2020-05-07T14:45:48Z")

</div>

could you try upgrading dash and let us know if you’re still facing the issue? we recently fixed many callback resolution bugs

---

<div class="post-metadata">

**Author:** ![rs\_201381](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@rs\_201381](https://community.plotly.com/u/rs_201381)\
**Post date:** [May 8, 2020, 5:46am UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051/3 "2020-05-08T05:46:32Z")

</div>

@chriddyp, I am still getting the same issue even after upgrade. Please help

---

<div class="post-metadata">

**Author:** ![chriddyp](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/chriddyp/32/16855_2.png) [@chriddyp](https://community.plotly.com/u/chriddyp)\
**Post date:** [May 8, 2020, 5:48am UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051/4 "2020-05-08T05:48:12Z")

</div>

OK, thanks for trying to upgrade! Could you simplify your code into a [simple, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) that we can run on our machines? Thanks!

---

<div class="post-metadata">

**Author:** ![rs\_201381](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@rs\_201381](https://community.plotly.com/u/rs_201381)\
**Post date:** [May 8, 2020, 6:47am UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051/5 "2020-05-08T06:47:31Z")

</div>

@chriddyp  
Below is the code. Tried to strip it and reproduced the error.  
To reproduce:

1. Run code as it is. Select a radio button. Text area will be filled with value. Click on “Create” button. Selected row will be removed from table above.
2. Un-comment the third callback re-run.
3. Perform above steps and nothing will work. e.g. selecting radio button will not populate text area

df = pd.DataFrame(np.random.randint(0,100,size=(5, 4)), columns=list(‘ABCD’))

app = dash.Dash( **name** , external\_stylesheets=[dbc.themes.BOOTSTRAP])

create\_button = dbc.Container([ dbc.Row( [ dbc.Button(‘Create’, id=‘submit-button’, n\_clicks=0, color=“primary”),  
dbc.Button(‘Refresh’, id=‘refresh-button’, n\_clicks=0, color=“success”)],  
justify=“center”, align=“center”, className=“h-50”)  
],style={“height”: “10vh”}  
)

app.layout = html.Div([ html.Div(id=‘alert-div’),  
html.Div([  
dash\_table.DataTable(  
id=‘table-dropdown’,  
data = df.to\_dict(‘records’),  
columns=[  
{‘id’: ‘A’, ‘name’: ‘A’, ‘editable’: False},  
{‘id’: ‘B’, ‘name’: ‘B’},  
{‘id’: ‘C’, ‘name’: ‘C’},  
{‘id’: ‘D Group’, ‘name’: ‘D’},  
],  
css = [{‘selector’: ‘tr:hover’, ‘rule’: ‘backgroundColor: pink;’}],  
editable=True,  
row\_selectable=‘single’,  
selected\_rows=  
),  
html.Div(id=‘table-dropdown-container’)  
], style={‘display’: ‘inline-block’}),  
dcc.Loading(id=“loading-1”, children=[html.Div(id=“loading-output-1”)], type=“default”),  
html.Div([  
dcc.Textarea(  
id=‘textarea-example’,  
value=‘Please select a row above to display the contents in this area’,  
style={‘width’: ‘100%’, ‘height’: 300, ‘fonSize’: 21},  
disabled=True,  
),  
create\_button,  
html.Div(id=‘textarea-example-output’, style={‘display’: ‘inline-block’, ‘whiteSpace’: ‘pre-line’})  
])  
], style={‘marginLeft’: 30, ‘marginRight’: 30, ‘display’: ‘inline-block’})

@app.callback(  
[Output(‘table-dropdown’,‘data’),  
Output(‘table-dropdown’,‘selected\_rows’),  
Output(‘alert-div’,‘children’),  
Output(‘refresh-button’,‘disabled’),  
Output(‘submit-button’,‘disabled’)],  
[Input(‘submit-button’,‘n\_clicks’)],  
[State(‘table-dropdown’, ‘selected\_rows’),  
State(‘table-dropdown’, ‘data’)],  
prevent\_initial\_call=True)  
def update\_datatable(n\_clicks, selected\_rows, data):  
global df  
print("\nupdate\_datatable")  
alert = None  
refresh\_hide = True  
create\_hide = False  
if n\_clicks:  
if selected\_rows:  
df = df.drop(selected\_rows[0]).reset\_index(drop=True)  
selected\_rows =   
return (df.to\_dict(‘records’), selected\_rows, alert, refresh\_hide, create\_hide)

@app.callback(  
Output(‘textarea-example’,‘value’),  
[Input(‘table-dropdown’, ‘selected\_rows’)],  
[State(‘table-dropdown’, ‘data’)],  
prevent\_initial\_call=True)  
def update\_textarea(selected\_rows ,data):  
print("\nupdate\_email")  
#print(selected\_rows)  
if selected\_rows:  
return data[selected\_rows[0]][‘A’]  
else:  
return “Please select a row above to display the contents in this area”

‘’’@app.callback([Output(‘table-dropdown’,‘data’),  
Output(‘table-dropdown’,‘selected\_rows’),  
Output(‘refresh-button’,‘disabled’),  
Output(‘submit-button’,‘disabled’)],  
[Input(‘refresh-button’,‘n\_clicks’)],  
prevent\_initial\_call=True)  
def refresh\_emails(n\_clicks):  
print("\nrefresh\_emails")  
refresh\_hide = False  
create\_hide = False  
if n\_clicks:  
refresh\_hide = True  
create\_hide = False  
return (email\_df.to\_dict(‘records’), , refresh\_hide, create\_hide)’’’

if **name** == ‘ **main** ’:  
app.run\_server(debug=False)

---

<div class="post-metadata">

**Author:** ![rs\_201381](https://avatars.discourse-cdn.com/v4/letter/r/b487fb/32.png) [@rs\_201381](https://community.plotly.com/u/rs_201381)\
**Post date:** [May 11, 2020, 3:59am UTC](https://community.plotly.com/t/chained-callbacks-not-working/39051/6 "2020-05-11T03:59:35Z")

</div>

@chriddyp, were you able to reproduce the issue? Did u get any solution ?
