Closed enviromachinebeast closed 6 months ago
Not sure if this is what you are looking to do, but I found you can reuse the same grid by putting it in a form.
with st.form(key='gridform'):
submit_button = st.form_submit_button(label='Submit')
if submit_button:
# if button pushed, run the query
df = runQuery(queryText,False)
print(df)
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_pagination()
gb.configure_side_bar()
gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc="sum", editable=False)
gridOptions = gb.build()
gridA = AgGrid(df, gridOptions=gridOptions, enable_enterprise_modules=True,reload_data=True, key= "grid1")
Likewise, you can specify 2 or more grids and determine which you want to display:
with st.form(key='gridform'):
submit_button = st.form_submit_button(label='Submit')
if submit_button:
# if button pushed, run the query
df = runQuery(queryText,False)
gb = GridOptionsBuilder.from_dataframe(df)
gb.configure_pagination()
gb.configure_side_bar()
gb.configure_default_column(groupable=True, value=True, enableRowGroup=True, aggFunc="sum", editable=False)
gridOptions = gb.build()
if showgrid == 1:
gridA = AgGrid(df, gridOptions=gridOptions, enable_enterprise_modules=True,reload_data=True, key= "grid1")
if showgrid == 2:
gridB = AgGrid(df, gridOptions=gridOptions, enable_enterprise_modules=True,reload_data=True, key= "grid2")
Once a strealit aggrid component is displayed, and in case another aggrid needs to be displayed and the earlier one needs to be undiplayed it does not happen. I tried it with st.experimental_reload() or displaying a second aggrid with different key.