if I dynamically add rows, how can automatically resize the grid when key-fixed?

I have a grid that has an “Add row” button. If I don’t add a fixed key, the grid sometimes disappear or doesn’t update correctly. If I add a fixed key, I can’t find a way to resize the grid (or the inner container to be able to do vertical scroll). In this example, you can’t scroll to see the new rows, and I don’t find a way to change the height of the grid dynamically. This is a simple version of my problem:

from st_aggrid import GridOptionsBuilder, AgGrid
import pandas as pd
import streamlit as st

data = {
    'Name': ['John Doe', 'Jane Smith', 'Emily Jones', 'Chris Brown', 'Elijah Wood'],
    'Age': [28, 34, 22, 45, 40],
    'City': ['New York', 'Los Angeles', 'Chicago', 'Houston', 'SFo']

gb = GridOptionsBuilder()
go = gb.build()

if "slides_df" not in st.session_state:
    st.session_state.slides_df = pd.DataFrame(data)

grid_response = AgGrid(

if st.button("Add row"):
    new_slide = {'Name': 'XXX', 'Age': 50}
    st.session_state.slides_df = pd.concat([st.session_state.slides_df, pd.DataFrame([new_slide])], ignore_index=True)

Any ideas? Thanks!

Hi @Alberto_A – We warmly welcome you to our community! :hugs:

Have you tried using configure_grid_options to set domLayout to 'autoHeight'? This instructs AgGrid to adjust its height automatically based on the number of rows, allowing the grid to expand and fit the content without requiring a vertical scrollbar.

I’m not entirely sure if @PablocFonseca , the creator of the (awesome!) Streamlit AgGrid component, has made this available as part of the component, but I think it would be worth trying.


That’s it @Charly_Wargnier . Setting the grid Height to None will activate auto height.

Good to see you back on the forums, Pablo! :hugs:

I hope you’re doing well, and thanks for your feedback.