streamlit-aggrid icon indicating copy to clipboard operation
streamlit-aggrid copied to clipboard

Adjustable table height

Open Joanna-Wojdylo opened this issue 2 years ago • 4 comments

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!

Joanna-Wojdylo avatar Mar 29 '22 09:03 Joanna-Wojdylo

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

PablocFonseca avatar Apr 07 '22 21:04 PablocFonseca

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

rhajou avatar Sep 12 '22 12:09 rhajou

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))

ghilesmeddour avatar Sep 13 '22 08:09 ghilesmeddour

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

rhajou avatar Sep 13 '22 12:09 rhajou