ID not found in layout

Hello,

whe I run app, I receive a below message:

Attempting to connect a callback Input item to component:
“datatable-paging”
but no components with that id exist in the layout.

If you are assigning callbacks to components that are
generated by other callbacks (and therefore not in the
initial layout), you can suppress this exception by setting
suppress_callback_exceptions=True.
This ID was used in the callback(s) for Output(s):
datatable-paging.data
datatable-paging.data

Can you please suggest how to fix it?
Thanks,
Tom

Hi @tkepic

The error is because exist a callback in your app that have as input an id=datatable-paging that is not present in the code.

Check if this id exist.

Hi Eduardo,

please see mentioned parts from my code:

PAGE_SIZE = 10
def create_DashTable(df):
    return dash_table.DataTable(
        id='datatable-paging',
        #data=df.to_dict('records'),
        columns=[{'name': i, 'id': i} for i in df.columns],
        page_current=0,
        page_size=PAGE_SIZE,
        page_action='custom'
    )



content = html.Div(id="page-content", children=[], style=CONTENT_STYLE)

app.layout = html.Div([
    dcc.Location(id="url"),
    sidebar,
    content
])

@app.callback(
    Output('datatable-paging', 'data'),
    Input('datatable-paging', "page_current"),
    Input('datatable-paging', "page_size"))
def update_table(page_current,page_size):
    return df_myTradesList.iloc[
        page_current*page_size:(page_current+ 1)*page_size
    ].to_dict('records')


@app.callback(
    Output("page-content", "children"),
    [Input("url", "pathname")]
)
def render_page_content(pathname):
    if pathname == "/":
        return [
                html.H1('TK TEST',
                        style={'textAlign':'center'}),
                dcc.Graph(id='bargraph',
                         figure=px.bar(df, barmode='group', x='Years',
                         y=['Girls Kindergarten', 'Boys Kindergarten']))
                ]
    elif pathname == "/page-1":
        return [
                html.H1('PAGE 1 Grad School in Iran',
                        style={'textAlign':'center'}),
                
                dcc.Graph(id='bargraph',
                         figure=px.bar(df, barmode='group', x='Years',
                         y=['Girls Grade School', 'Boys Grade School']))
                ]
    elif pathname == "/page-2":
        return [
                html.H1('myTradesList data',
                        style={'textAlign':'center'}),
                html.P(
                            "myTradesList:" , className="lead"
                        ),
                create_DashTable(df_myTradesList) 
                ]
    # If the user tries to reach a different page, return a 404 message
    return dbc.Jumbotron(
        [
            html.H1("404: Not found", className="text-danger"),
            html.Hr(),
            html.P(f"The pathname {pathname} was not recognised..."),
        ]
    )


if __name__=='__main__':
    app.run_server(debug=True, port=3001)

so, not sure now

Hey @tkepic
I think that your id=‘datatable-paging’ is part of a function (def create_DashTable(df)) that is not part of the app.layout = html.Div([
At least at the begining. I think the callback do not recognice the id because is not in the layout.
Thats why the error said:
If you are assigning callbacks to components that are
generated by other callbacks (and therefore not in the
initial layout), you can suppress this exception by setting
suppress_callback_exceptions=True.

See possible solution here:

https://dash.plotly.com/advanced-callbacks

Can you please specify more how you did this?
I am facing exactly the same issue

app = Dash(
name,
suppress_callback_exceptions=True
)

I did this which gets rid of error.