-
Notifications
You must be signed in to change notification settings - Fork 41
Open
Description
Describe your context
dash 3.3.0
dash_ag_grid 32.3.4
Describe the bug
When grid is initialized with empty rowData (which are later filled in through a callback) and a persisted filterModel prop, the persisted prop is cleared.
Expected behavior
The filterModel prop is used and not cleared.
MWE
Run the following snippet, click the Add data button and set a filter on the text column. Refresh the page. Observe that the filter is no longer set. In case the rowData is not empty, everything works as expected and the filter is set after the page is refreshed.
import dash_ag_grid as dag
from dash import Dash, Input, Output, callback, html
layout = [
dag.AgGrid(
id="ag-grid",
rowData=[
# {"number": 1, "text": "a"},
],
columnDefs=[
{"field": "number", "filter": "agNumberColumnFilter"},
{"field": "text", "filter": "agTextColumnFilter"},
],
persistence=True,
persisted_props=["filterModel"],
),
html.Button(
"Add data",
id="button",
),
]
@callback(
Output("ag-grid", "rowData"),
Input("button", "n_clicks"),
prevent_initial_call=True,
)
def add_data(_):
return [
{"number": 1, "text": "a"},
{"number": 2, "text": "b"},
]
app = Dash(__name__)
app.layout = layout
app.run()
Metadata
Metadata
Assignees
Labels
No labels