zauberzeug / nicegui

Create web-based user interfaces with Python. The nice way.
https://nicegui.io
MIT License
9.79k stars 580 forks source link

Column width setting in ui.aggrid is not working #1336

Closed CrystalWindSnake closed 1 year ago

CrystalWindSnake commented 1 year ago

Description


ui.aggrid(
    {
        "defaultColDef": {
            "width": 20,
        },
        "columnDefs": [
            {"field": "a"},
            {"field": "b"},
        ],
        "rowData": [{"a": 1, "b": 2}],
    }
)

ui.run()

The column width of the table is automatically set to fit.

falkoschindler commented 1 year ago

You're right, @CrystalWindSnake: ui.aggrid automatically scales all columns to fit the overall grid width: https://github.com/zauberzeug/nicegui/blob/e083e3f06aa13ebe4b5d457b9587dc7d7a047e26/nicegui/elements/aggrid.js#L11

This seemed to be a useful default behavior, but might lead to confusion when a fixed width is desired. Should we remove this line? Or should we extend the documentation?

For now you can add the following property to the columnDefs or defaultColDef:

            "suppressSizeToFit": True,
CrystalWindSnake commented 1 year ago

@falkoschindler Thanks for your help