Aggrid Table disappears, zooming in and out fixes

Hi All,

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?

Thanks!

There is a guide that may help how to solve your issue. Have you tried searching similar issue in this forum?

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() 

Hi, this issue sounds like the same one reported here: Bug: Table not always rendering when used inside tab · Issue #159 · PablocFonseca/streamlit-aggrid · GitHub

I have proposed a fix with this PR: Fix issue with st.tabs where grids on inactive tabs disappear by broccoliboy · Pull Request #204 · PablocFonseca/streamlit-aggrid · GitHub

I would appreciate anyone who can test the PR and provide some feedback. Thanks!

1 Like

@broccoliboy thank you! I just tried to install it using:

pip3 install git+https://github.com/broccoliboy/streamlit-aggrid.git

I am getting this error after:

Any idea how to resolve? I am using a mac with zsh terminal

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!

2 Likes

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

Please see Bug: Table not always rendering when used inside tab · Issue #159 · PablocFonseca/streamlit-aggrid · GitHub for instructions on building the frontend from source to test the proposed fix.

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.