How to intercept row deletion action from DataTable


I have a Dash DataTable with row_deletable=True. When the user deletes a row, I want to issue an http post request, based on the data of the row that was deleted.

Eg, if the user deletes the row below with State=“California”, I want to make a post request with “California” in the payload.

I’ve created a working example where I compare data to data_previous. Is this the most efficient way? Is it necessary to create this empty_div, since I don’t need the callback to change any Output?

import dash
import dash_table
import pandas as pd
import dash_html_components as html
from dash.dependencies import Input, Output, State
from dash.exceptions import PreventUpdate

df = pd.read_csv('')

app = dash.Dash(__name__)

app.layout = html.Div([
        columns=[{"name": i, "id": i} for i in df.columns],

@app.callback(Output('empty_div', 'children'),
              [Input('table', 'data')],
              [State('table', 'data_previous')])
def engine_pool_list(data,data_previous): #,refresh_clicks
    data_previous = data_previous or [] # ensure we deal with empty list rather than None
    data = data or []
    data_dropped = [x for x in data_previous if x not in data]
    for row in data_dropped:
        print(f'dropped {row["State"]}')
    raise PreventUpdate

if __name__ == '__main__':

Thank you!