Set undoRedoCellEditing
on dashGridOptions
to True
to allow users to undo and redo their cell edits when cell editing is enabled. Use undoRedoCellEditingLimit
to configure the number of allowed undo/redo steps. The default is 10
.
dag.AgGrid(
columnDefs=columnDefs,
rowData=df.to_dict("records"),
dashGridOptions={
'undoRedoCellEditing': True,
'undoRedoCellEditingLimit': 20
}
)
Undo and Redo Shortcuts
The following keyboard shortcuts are available when undo/redo cell editing is enabled:
- Ctrl+Z (Windows) / Command+Z (Mac): will undo the last cell edit(s).
- Ctrl+Y (Windows) / Command+Shift+Z (Mac): will redo the last undo.
Note: The grid needs focus for these shortcuts to work.
import dash_ag_grid as dag
from dash import Dash, html, dcc
import pandas as pd
app = Dash(__name__)
df = pd.read_csv("https://raw.githubusercontent.com/plotly/datasets/master/wind_dataset.csv")
app.layout = html.Div(
[
dag.AgGrid(
id="undo-redo-cell-editing-example",
rowData=df.to_dict("records"),
columnDefs=[{"field": i} for i in df.columns],
columnSize="sizeToFit",
defaultColDef={"editable": True},
dashGridOptions={
"undoRedoCellEditing": True,
"undoRedoCellEditingLimit": 20,
"editType": "fullRow",
},
),
],
style={"margin": 20},
)
if __name__ == "__main__":
app.run(debug=False)