Hello everybody,
i am facing an issue with the property “undoRedoCellEditing”. Without a callback that changes the content of “rowData” i am able to undo/redo the edited cell (Key CTRL-Z). As soon as this callback is activated this property (Key CTRL-Z) has no effect
Thanks in Advance. I would appreciate any help. I’ve just switched from dash.dataTable to AgGrid.
AgGrid definition
grid = dag.AgGrid(
id="portfolio-grid",
className="ag-theme-alpine-dark",
columnDefs=columnDefs,
rowData=df.to_dict("records"),
columnSize="sizeToFit",
defaultColDef=defaultColDef,
dashGridOptions={"undoRedoCellEditing": True, 'rowSelection': "multiple", 'rowDragManaged': True, 'domLayout': 'autoHeight'},
style={"height": "100%", "width": "100%"},
)
callback: I have even tried to return the dashGridOptions. But it showed no effect.
This callback is just to control the type/format of the cells. Probably there is a clever and simpler way to perform it…
@app.callback(
Output("portfolio-grid", "rowData", allow_duplicate=True),
Output("portfolio-grid", "dashGridOptions"),
Input("portfolio-grid", "cellValueChanged"),
State("portfolio-grid", "rowData"),
State("portfolio-grid", "dashGridOptions"), prevent_initial_call=True
)
def update(cell_changed, rowData, dashGridOptions):
if cell_changed is not None:
row_index = cell_changed['rowIndex']
col_id = cell_changed['colId']
old_value = cell_changed['oldValue']
new_value = cell_changed['value']
if col_id in ['Column_A', 'Column_B', 'Column_C', 'Column_D']:
# if new_value.lstrip('-').isdigit():
try:
if float(new_value):
rowData[row_index][col_id] = new_value
except ValueError:
if col_id in ['Column_E', 'Column_F'] and new_value == '':
rowData[row_index][col_id] = new_value
else:
rowData[row_index][col_id] = old_value
dashGridOptions["undoRedoCellEditing"] = True
return rowData, dashGridOptions
else:
return dash.no_update