Hi!
I have some issues in filtering my data using Dash AG Grid.
date colum:
0 2015-01-08
1 2015-01-08
2 2015-01-15
3 2015-01-15
4 2015-01-15
5 2015-01-15
Name: Fecha de monitoreo, dtype: datetime64[ns] datetime64[ns]
(Type: datetime)
Acording with AG grid documentation i have to change to str:
Note - the filter works for dates only, not datetime. So if your date string looks like “2023-01-01T22:00:00” you will first need to change it to date string i.e. “2023-01-01”
colName_dates = 'Fecha de monitoreo'
df[colName_dates] = df[colName_dates].dt.strftime('%d-%m-%Y')
got this:
0 08-01-2015
1 08-01-2015
2 15-01-2015
3 15-01-2015
4 15-01-2015
5 15-01-2015
Name: Fecha de monitoreo, dtype: object object
Note: i changed date format
So then, i use this code:
dash_grid = dag.AgGrid(
id="dash_grid",
rowData=df.to_dict("records"),
columnDefs=[
{
"field": colName_dates,
"filter": "agDateColumnFilter",
"valueGetter": {"function": f"d3.timeParse('%d-%m-%Y')(params.data.{colName_dates})"},
"valueFormatter": {"function": f"params.data.{colName_dates}"},
},
{"field": colName_station, "filter": "agTextColumnFilter"},
{"field": parameter, "filter": "agNumberColumnFilter"},
],
defaultColDef={"resizable": True, "sortable": True, "filter": True, "minWidth":125},
)
It display well the AG Grid, but when filter the dates columns, doesnt works.
(The others columns works fine the filter)
what am I doing wrong?
**The filter doesnt works**