PablocFonseca / streamlit-aggrid

Implementation of Ag-Grid component for Streamlit
https://pypi.org/project/streamlit-aggrid/
MIT License
1.05k stars 199 forks source link

Auto size all columns not work as expected #205

Open zbjdonald opened 1 year ago

zbjdonald commented 1 year ago

The current implementation of the columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS feature may not be working as expected. It seems that only some columns are properly sized and that you need to click the "Autosize Columns" button once to ensure that all columns are sized correctly.

broccoliboy commented 1 year ago

Could this be related to auto sizing limitations due to virtualization? https://www.ag-grid.com/javascript-data-grid/column-sizing/#auto-size-columns

zbjdonald commented 1 year ago

Wait your new release, thank you for your help.

Alessandro201 commented 1 year ago

Could this be related to auto sizing limitations due to virtualization? https://www.ag-grid.com/javascript-data-grid/column-sizing/#auto-size-columns

Thank you, this fixed it for me. In case anyone having the same problem wants to know how to implement it, this is my code:

from st_aggrid import GridOptionsBuilder, AgGrid, ColumnsAutoSizeMode

df = ### make your pandas dataframe ###

gb = GridOptionsBuilder.from_dataframe(df)
other_options = {'suppressColumnVirtualisation': True}
gb.configure_grid_options(**other_options)
gridOptions = gb.build()

grid = AgGrid(df, gridOptions=gridOptions, columns_auto_size_mode=ColumnsAutoSizeMode.FIT_CONTENTS)