PablocFonseca / streamlit-aggrid

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

Adjustable table height #72

Closed Joanna-Wojdylo closed 6 months ago

Joanna-Wojdylo commented 2 years ago

Hi! First of all, I would like to say a big thanks to the creators of AgGrid! Great work and a very cool component! :)

I would like to ask if you have thought maybe about the possibility of automatic height adjustment? It would be great if you could give some flag like adjust_height=True and the height parameter would be the maximum height to which the table can stretch. I ask about it, because in case of height defined for specific value like 500, in case of smaller number of data there is a lot of empty space left, which could dynamically shrink. Or maybe there is already some way to achieve something similar?

Thanks for your answer and best regards!

PablocFonseca commented 2 years ago

check https://streamlit-aggrid.readthedocs.io/en/docs/GridOptionsBuilder.html#st_aggrid.grid_options_builder.GridOptionsBuilder.configure_auto_height

rhajou commented 2 years ago

Hello @PablocFonseca , fantastic library!

I just have one question, how can we specify height to be adjustable to the number of rows in the table? for example: I have table with 1 row but shows in addition to that empy space below this row.

image

ghilesmeddour commented 2 years ago

Hi @rhajou. If autoHeight does not meet your needs, you can use some custom logic. For example:

MIN_HEIGHT = 50
MAX_HEIGHT = 800
ROW_HEIGHT = 60

AgGrid(df, height=min(MIN_HEIGHT + len(df) * ROW_HEIGHT, MAX_HEIGHT))
rhajou commented 2 years ago

Hello @ghilesmeddour , thank you I just figured that out as well :) ! Although I think the best values are:

MIN_HEIGHT = 27 MAX_HEIGHT = 800 ROW_HEIGHT = 35