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()
gb.configure_column("Name")
gb.configure_column("Age")
gb.configure_column("City")
go = gb.build()
if "slides_df" not in st.session_state:
st.session_state.slides_df = pd.DataFrame(data)
grid_response = AgGrid(
st.session_state.slides_df,
fit_columns_on_grid_load=True,
gridOptions=go,
key="fixed",
)
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)
st.rerun()
Any ideas? Thanks!