Async Nested Tables

Hydrate child rows from callbacks while preserving the same nested table interaction model.

Async Nested Tables

Hydrate child rows from callbacks while preserving the same nested table interaction model.

Source: usage.py::build_async_nested_tables_code().

pending_ids = dcc.Store(id="async-nested-pending-company-ids", data=[])
loader = dcc.Interval(id="async-nested-loader", interval=450, disabled=True, n_intervals=0)

table = (
    dmdt.DataTable(
        id="async-nested-tables-table",
        data=build_async_nested_company_records(),
        columns=NESTED_GROUPED_COLUMNS,
        paginationMode="none",
        child_rows_accessor="childrenData",
        group_aggregations=NESTED_GROUP_AGGREGATIONS,
    )
    .update_layout(radius="lg", withTableBorder=True, withColumnBorders=True, striped=True)
    .update_rows(expandedRecordIds=["northwind"])
)

@callback(
    Output("async-nested-tables-table", "data"),
    Output("async-nested-pending-company-ids", "data"),
    Output("async-nested-loader", "disabled"),
    Output("async-nested-loader", "n_intervals"),
    Input("async-nested-tables-table", "expandedRecordIds"),
    State("async-nested-tables-table", "data"),
)
def queue_async_company_load(expanded_ids, current_rows):
    ...

@callback(
    Output("async-nested-tables-table", "data", allow_duplicate=True),
    Output("async-nested-pending-company-ids", "data", allow_duplicate=True),
    Output("async-nested-loader", "disabled", allow_duplicate=True),
    Input("async-nested-loader", "n_intervals"),
    State("async-nested-pending-company-ids", "data"),
    State("async-nested-tables-table", "data"),
    prevent_initial_call=True,
)
def hydrate_async_company_load(n_intervals, pending_ids, current_rows):
    ...