Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Width statement in columnDefs of grid options is ignored #265

Open
mmf431 opened this issue Apr 15, 2024 · 3 comments
Open

Width statement in columnDefs of grid options is ignored #265

mmf431 opened this issue Apr 15, 2024 · 3 comments

Comments

@mmf431
Copy link

mmf431 commented Apr 15, 2024

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
Copy link
Owner

Could you please share some code?

@mmf431
Copy link
Author

mmf431 commented Apr 15, 2024

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
Copy link
Author

mmf431 commented Apr 15, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants