Hi all,
I’m using aggrid to allow my users to make changes in the displayed data. It works well with low volume changes, but once they edit ~1k rows, it takes ages for aggrid to return the grid data.
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid, GridOptionsBuilder
# Generate a medium-sized DataFrame
data = {
"Name": [f"Person {i}" for i in range(1, 1001)],
"Age": [i % 50 + 20 for i in range(1, 1001)],
"City": [f"City {i % 10}" for i in range(1, 1001)],
"Salary": [i * 1000 for i in range(1, 1001)],
"Department": [f"Dept {i % 5}" for i in range(1, 1001)],
}
df = pd.DataFrame(data)
# Streamlit App
st.title("Interactive Ag-Grid Table in Streamlit")
# Configure Ag-Grid options
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_column(**{
"field":"City",
"cellDataType":"text",
"headerName":"City",
"editable":True,
"cellEditor":"agTextCellEditor"
})
gb.configure_selection(selection_mode='multiple', use_checkbox=True, header_checkbox = True)
gb.configure_grid_options(enableRangeSelection=True) # Enables selecting multiple cells
gb.configure_grid_options(enableFillHandle=True, fillHandleDirection='y') # Enables drag down to fill cells
grid_options = gb.build()
# Display the Ag-Grid table
s = AgGrid(df, gridOptions=grid_options, height=400, fit_columns_on_grid_load=True, editable=True)
st.write(s["data"])`
If you change the first value of the City column to anything, then you drag it down straight to the end of the table, it takes couple of minutes for Aggrid to return the updated s[“data”], and sometimes it even kills the browsers. Is this an issue with the streamlit implementation? Anyone has any idea of a workaround?