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
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.