pywebio / PyWebIO

Write interactive web app in script way.
https://pywebio.readthedocs.io
MIT License
4.53k stars 384 forks source link

Datatables do not respect the `flex` `column_arg` #570

Closed amks1 closed 1 year ago

amks1 commented 1 year ago

As per the documentation here and here, the flex key should be able to resize the columns to fit the page width in proportion to the flex values given.

Here's my code:

def test_pywebio():
    row = {
        "Col1": "1",
        "Col2": "asddddddda",
        "Col3": "asdasd",
        "Col4": "asdasdasd",
        "Col5": "asd",
        "Col6": "asd",
        "Col7": "asd",
        "Col8": "asdasdasdas",
        "Col9": "asdasda",
    }
    col_args = {
        "Col1": {"flex": 1},
        "Col2": {"flex": 6},
        "Col3": {"flex": 2},
        "Col4": {"flex": 2},
        "Col5": {"flex": 2},
        "Col6": {"flex": 2},
        "Col7": {"flex": 2},
        "Col8": {"flex": 6},
        "Col9": {"flex": 2},
    }

    pywebio.output.put_datatable([row], column_args=col_args, height='auto')

Here's the output:

image

As you can see, the flex values are not being considered. I also tried using maxWidth, minWidth and width values, and although there are some changes to the table sizes, it does not work as documented.

Environment Information

wang0618 commented 1 year ago

pywebio will call gridOptions.columnApi.autoSizeAllColumns() when the grid is ready, which will make the grid ignore the flex setting on column.

I will consider to update code to disable auto size column when user provide column sizing settings.