I get an âError loading layoutâ failure in the browser. The reason is the Input of selected_objects. The debugger never entered the method body. I assume that the value of children could be None. I am not a frontend or python developer and this frustrated me because I donât get any additional information about the reason and I havenât the time to go deep into the mechanics.
I will be happy if anyone has some information about the failure and how I can handle this.
Oh, thx. This was a copy paste problem to the forum. I have fixed that. The failure occures to the input component, if I use another input component, all will rendered
Thy for your response. The failure doesnât depends on the count of the input parameter. I created a minimal example code that you can reproduce the failure:
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Output, Event, Input, State
import dash_table as dt
app = dash.Dash(__name__)
app.layout = html.Div([
html.Div([
html.Div([
html.H3('Area'),
dcc.Graph(
id='area',
),
]),
html.Div([
dcc.Graph(id='object-travel-in-area'),
dcc.Graph(id='relationship-from-an-object'),
]),
], style={'columnCount': 2}),
html.Div(children=[
html.H3(children='Matching Objects'),
dt.DataTable(
sorting_type="multi",
row_selectable="multi",
row_deletable=True,
selected_rows=[],
id='datatable-filtered-Objects'
), html.Div(id='datatable-interactivity-container')
]),
html.Div(id='selected_objects',
style={'display': 'none'},
children=[]
),
html.Div(id='filtered_objects',
style={'display': 'none'},
children=[]
)
], style={"height": "100vh"})
@app.callback(Output('datatable-filtered-Objects', 'selected_rows'),
[Input('selected_objects', 'children')], )
def update_selected_object_table(selected_objects_json):
return []
@app.callback(
Output('selected_objects', 'children'),
[
Input('area', 'clickData'),
Input('datatable-filtered-Objects', 'selected_rows'),
]
)
# if I clicked on the graph or on the table, the selected_objects should updated
def update_selected_object_ids(dataA, dataB):
return [] # This line will never entered though the debuger
if __name__ == '__main__':
app.run_server(debug=True)
I think I saw a post yesterday about your issue, and Chris explained it wasnât implemented yet.
What your code is doing is basically an infinite loop of callbacks.
So callback1 triggers callback2, which trigger callbacks1, etc.
One way to avoid such loop would be to change your callback2. Since you have 2 inputs, you can change the âdatatable-filtered-Objectsâ from Input to State, and the loop will be broken. However, callback2 will only be triggered when âareaâ, âclickDataâ is clicked
New Callback2:
OUTPUT = âselected_objectsâ, âchildrenâ
INPUT = âareaâ, âclickDataâ
STATE = âdatatable-filtered-Objectsâ, âselected_rowsâ