Hi,
i have some issues with column groups and datetime columns:
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder
import pandas as pd
# without groups:
df = pd.DataFrame({"colA":["a", "b", "c"],
"colB":["a", "b", "c"],
"colC":["2022-01-01", "2022-02-01", "2022-03-01"]})
df["colC"] = pd.to_datetime(df["colC"])
gb = GridOptionsBuilder.from_dataframe(
df
)
selection = AgGrid(
df,
enable_enterprise_modules=True,
gridOptions=gb.build()
)
# with groups:
df2 = pd.DataFrame({"colA":["a", "b", "c"],
"colB":["a", "b", "c"],
"colC":["2022-01-01", "2022-02-01", "2022-03-01"]})
df2["colC"] = pd.to_datetime(df2["colC"])
gb = GridOptionsBuilder.from_dataframe(
df2
)
gb.configure_column("group1",
header_name="group1",
children=[
{
"field": 'colA'
},
{
"field": 'colB'
},
{
"field": 'colC'
},
]
)
selection2 = AgGrid(
df2,
enable_enterprise_modules=True,
gridOptions=gb.build(),
key="grid2"
)
In the second Grid, with groups, columns are duplicated AND the datatype of the grouped columns is set to string, so that here, the datepicker-filter does not work.
If i change the df of the gridbuilder options to an empty dataframe, i have all groups set up properly, but the datecolumn is of type string.
I can adjust the configuration of the column as:
{
"field": 'colC',
"type":"customDateTimeFormat",
"custom_format_string":'yyyy-MM-dd',
"filter": 'agDateColumnFilter'
},
But the filter won’t work, as the column is not recognized as dates.
Has anyone seen similar behaviour? Am i missing something?
Best,
Max