回调中更新的破折号 table 不会显示

Dash table updated in callback won't display

我正在构建 Dash 应用程序。我有一个 table 的搜索结果,并且行 select 可用。我想要第二个 table,只有第一个 table 中的行 select。因此,第二个 table 的数据在回调函数中更新。

以下是代码示例:

布局:

html.Div([
        html.Div(id='selection-table'),
        dash_table.DataTable(
            id='result-table',
            columns=[{"name": i, "id": i, "selectable": True} for i in df_results.columns],
            data=df_results.to_dict('records'),
            row_selectable="multi",
            selected_rows=[],
            style_as_list_view=True,
            style_data={
                'whiteSpace': 'normal',
                'height': 'auto'
            },
            style_cell_conditional=[
                {'if': {'column_id': 'id'},
                'width': '5%'},
                {'if': {'column_id': 'targetsCount'},
                'width': '10%'},
            ]
        )
    ], 
    className='results'
    )

回调:

@dash_app.callback(Output('selection-table', 'children'),
                    [Input('result-table', 'data'),
                    Input('result-table', 'selected_row_ids')])
def display_result_selection(data, selected_row_ids):
    if selected_row_ids is None:
        selected_row_ids = []
    df = pd.DataFrame() if data is None else pd.DataFrame(data)
    df = df[df['id'].isin(selected_row_ids)]
    print(df)
    return [
            html.P('Current selection'),
            html.P(' '.join(df['id'].tolist())),
            dash_table.DataTable(
                columns=[{"name": i, "id": i, "deletable": True} for i in df.columns],
                data=df.to_dict(),
                row_deletable=True,
                style_as_list_view=True,
                style_data={
                    'whiteSpace': 'normal',
                    'height': 'auto'
                }
            )
        ]

预期结果:当我在result-select中有一行时-table,我想在table里面有一个新行select离子-table

真实结果:

我正在使用 Python 3.8.3 和 Dash 1.16.3。

知道我在这里遗漏了什么吗? 非常感谢

正如 Frayal 在评论中提到的那样,data=df.to_dict('records') 成功了,因此字典结构良好。