PablocFonseca / streamlit-aggrid

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

Width statement in columnDefs of grid options is ignored #265

Open mmf431 opened 2 months ago

mmf431 commented 2 months ago

Since I made the update from 1.0 to 1.2 my width statement in a columnDef is ignored and the column gets much too broad trying to accomodate all text that is in the largest cell of the column.

PablocFonseca commented 2 months ago

Could you please share some code?

mmf431 commented 2 months ago

builder = GridOptionsBuilder.from_dataframe(df)

builder.configure_selection( selection_mode='single', suppressRowClickSelection=False ) grid_options = builder.build()

grid_options['defaultColDef'] = {'filter': True}

grid_options['columnDefs'] = [
    {'headerName': 'Datum', 'field': 'DATUMZU', 'flex': 1},
    {'headerName': 'Bezeichnung', 'field': 'BEZEICHNUNG', 'editable': st.session_state['edit_mode'], 'width': 200},
    {'headerName': 'Art', 'field': 'DOMEART', 'flex': 1},
    {'headerName': 'Kategorie-Bez.', 'field': 'KATEGBEZ', 'flex': 1},
    {'headerName': 'Bereich-Bez.', 'field': 'BEREICHBEZ', 'flex': 1},
    {'headerName': 'Status-Bez.', 'field': 'STATUSBEZ', 'flex': 1},
    {'headerName': 'pkey', 'field': 'pkey', 'flex': 1},
] 

    # Display the ag-Grid
    ag = AgGrid(df,      
        height=315,
        gridOptions=grid_options,
        update_mode = GridUpdateMode.VALUE_CHANGED | GridUpdateMode.SELECTION_CHANGED,
        enable_enterprise_modules=False,
        allow_unsafe_jscode=True,
        key='docgrid'
    )
mmf431 commented 2 months ago

What I recognized is that the grid is displayed correctly in the second and each subsequent run.