Load data dynamically in AG Grid

Hey everyone,

I have a dash AG Grid table and it gets populated with an api call.

@callback(
    [
        Output("bulk-table", "rowData", allow_duplicate=True),
        Output("num_of_agreements", "children"),
    ],
    [
        Input("filter1", "value"),
    ],
    prevent_initial_call=True,
)
def update_table(selected_filter: str) -> list:
    if selected_filter:
        all_data = []
        next_id = None

        try:
            while True:
                pa = api.get_data(
                    selected_filter=selected_filter,
                    from_id=next_id,
                )

                flat = [flatten_data(test_data) for test_data in pa['items']]
                for sublist in flat:
                    for item in sublist:
                        all_data.append(item)

                next_id = pa['next_id']
                total = pa['total']
                if next_id is None:
                    break

        except Exception:
            return [], 0

        if not all_data:
            return [], 0

        return all_data, total

    return [], 0

it’s using pagination in the backend. And what it does, it just is making the calls as long as there is a next_id.

What I would like to have is to load the data in the table as it receives data. So the table gets populated as new data comes in, or make it in batches or similar.

Also in the data I receive the total and how many are loaded.
Can I show somehow in a component ‘X out of total loaded’.
I have tried with the total to show it, but now it only shows the total AFTER the callback is finished and all data returned (the total number is available in the data from the first load).
Is there any component that dynamically changes?

Hello @kjurukova,

If you want to add data to the grid, you can use rowTransaction and you can use a background callback with a set progress to stream the data back to the grid.

Callbacks, will only return info with the return statement, in your callback that you have, you are only returning once you have all the data.