I have Aggrids table in streamlit tabs. If I interact with the rest of the dashboard, then the tables in the other tabs that are not currently being displayed disappear. However, zooming in and out on the page seems to rerender the table. Has anyone else seen this and knows a fix?
Hello @ferdy, sorry for the delay. Here is minimal produceable code of the bug. For context, I need the table to be editable, and for the edits to stick through the session, which is why i added a key to the aggrid object that updates when edits are made.
I also have a screen recording, how can I share it here?
Please let me know if you can think of any fixes
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid, GridOptionsBuilder
if 'aggrid_key' not in st.session_state:
st.session_state.aggrid_key = 0
def main():
st.set_page_config(layout="wide",page_title="test",) #set the page view configs
st.sidebar.write(f'Welcome')
form = st.form('Form')
tabs = form.tabs(['Tab1','Tab2'])
for tab in range(len(tabs)):
tab_obj = tabs[tab].container()
df = pd.read_csv("test_params.csv")
with tab_obj:
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_default_column(editable=True)
data = AgGrid(
df,
gridOptions=gb.build(),
key=f'{st.session_state.aggrid_key}_{tab}_ag',
reload_data=False,
data_return_mode=DataReturnMode.AS_INPUT,
update_mode=GridUpdateMode.MODEL_CHANGED,
)
submit = form.form_submit_button()
if __name__ == '__main__':
main()
Unfortunately this package is not pip installable directly from git. You’ll have to clone/download the repo, build the frontend, and then install with pip. To build the frontend, make sure node.js and yarn are installed, then after cloning/downloading the repo run yarn && yarn build. This will generate st_aggrid/frontend/build. Then, from the base repo directory run pip install . to install the package from the current directory.
Hey @broccoliboy, thank you so much! that process worked. Unfortunately that update did not work for me - the tables still seem to disappear when a button is clicked.
Thank you for testing! I just tested and saw similar issues with your example code. I updated the way streamlit-aggrid determines when to update its container size and just pushed a new commit to my repo. Please pull the latest, rebuild, and test again. Thanks!
Hi, I am having the same error (the grid is inside a tab if I use the widget on another tab the grid disappears, it only appears if I zoom in or refresh the page). I just update streamlit-aggrid (version 0.3.4.post3) but it didn’t work