streamlit-aggrid icon indicating copy to clipboard operation
streamlit-aggrid copied to clipboard

Auto size all columns not work as expected

Open zbjdonald opened this issue 1 year ago • 3 comments

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.

zbjdonald avatar Mar 23 '23 09:03 zbjdonald

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

broccoliboy avatar Mar 23 '23 14:03 broccoliboy

Wait your new release, thank you for your help.

zbjdonald avatar Mar 24 '23 02:03 zbjdonald

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)

Alessandro201 avatar Mar 30 '23 16:03 Alessandro201