I’d like to have add a thousand separator (preferably a blank space) to my numeric values in an Ag Grid table, in my Streamlit application.
The function I use to build it is this one :
def render_aggrid(df: pd.DataFrame, column_list: list[str]) -> dict:
# Build grid options
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_default_column(filter=True) # Enable filtering for all columns
# Set specific widths for individual columns
for col in column_list:
gb.configure_column(col)
grid_options = gb.build()
grid_options["suppressSizeToFit"] = True
# Display with AgGrid
grid_response = AgGrid(
df,
gridOptions=grid_options,
enable_enterprise_modules=True,
fit_columns_on_grid_load=True,
)
return grid_response
I tried adding a valueFormatter to my numeric columns (valueFormatter="params.value.toLocaleString('fr-FR')"
).
I see that this line print(f"{col_def['field']}: {col_def.get('valueFormatter')}")
is telling me that the valueFormatter is as expected, but I don’t see any thousand separator in my Ag Grid table.
Am I missing something ?