Here you go:
import dash_ag_grid as dag
from dash import Dash, html, dcc, Input, Output, callback, State, clientside_callback, no_update
import plotly.express as px
app = Dash(__name__)
df = px.data.gapminder()
app.layout = html.Div(
[
dcc.Markdown("Example of using `cellValueChanged` in a callback"),
dcc.Interval(id='test', interval=1000),
dcc.Input(id='cell-editing'),
dag.AgGrid(
id="editing-grid",
columnDefs=[{"field": i} for i in df.columns],
rowData=df.to_dict("records"),
columnSize="sizeToFit",
defaultColDef={"editable": True, "minWidth": 120},
),
html.Div(id='interval-response')
],
style={"margin": 20},
)
clientside_callback(
""" function (id) {
dash_ag_grid.getApiAsync(id).then((grid) => {
grid.addEventListener("cellEditingStarted", () => {
document.getElementById("cell-editing").defaultValue = "True"
document.getElementById("cell-editing").dispatchEvent(new Event("input", { bubbles: true }))
})
grid.addEventListener("cellEditingStopped", () => {
document.getElementById("cell-editing").defaultValue = "False"
document.getElementById("cell-editing").dispatchEvent(new Event("input", { bubbles: true }))
})
})
return dash_clientside.no_update;
}""",
Output("editing-grid", "id"),
Input("editing-grid", "id")
)
@callback ( Output('interval-response','children', allow_duplicate=True),
[Input('test','n_intervals'),
State('cell-editing', 'value')],
prevent_initial_call = True)
def update_grid (intervals,cellediting):
if cellediting == "True":
print('test')
return no_update
return intervals
if __name__ == "__main__":
app.run(debug=True)
And yes, this does make a difference about the quotes, because they arent valid characters in the code. This is something that phones do when typing.
I fixed the actual code to work, but the mechanism was still the same. 