Any idea why this is not working
If i move sis’s code inside a st.button block, row selection is not returning anything
import numpy as np
import pandas as pd
import streamlit as st
from st_aggrid import AgGrid, GridOptionsBuilder, shared
np.random.seed(42)
def fetch_data():
dummy_data = {
"date": pd.date_range("2020-01-01", periods=5),
"group": list("AAABB"),
"apple": np.random.randint(0, 10, 5),
"banana": np.random.randint(0, 10, 5),
"chocolate": np.random.randint(0, 10, 5),
}
return pd.DataFrame(dummy_data)
def display_table(df: pd.DataFrame) -> AgGrid:
# Configure AgGrid options
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_selection("single")
return AgGrid(
df,
gridOptions=gb.build(),
# this override the default VALUE_CHANGED
update_mode=shared.GridUpdateMode.MODEL_CHANGED,
)
x = st.button("display table")
if x:
t = display_table(fetch_data())
st.json(t["selected_rows"])
@PablocFonseca Could you please check what is wrong here ? I’m using version 1.0.0