Hi!
In the example code below I basically have a 3x2 table and a session state list variable with all the names in the table. I’m printing this session state list before and after displaying the AgGrid.
Ok, following this example: we just entered the page and filtered the “Age” column to values greater than 3. Now, the markdown after the list only shows the values “A” & “B”. Of course, the code got executed again from the start so it makes sense. The thing is that the markdown before the table is still seeing “C”, it would need another rerun to not see it.
My goal is to somehow make the code knows a priori (before displaying the AgGrid table) which rows are currently selected on the filter. In other words, when the user filters the table, the code automatically gets run again, so I want to know which rows of the table are “active” (not filtered) before I display the table.
import streamlit as st
import pandas as pd
from st_aggrid import AgGrid
st.set_page_config(page_title = 'test'')
df = pd.DataFrame({'Name': ['A', 'B', 'C'], 'Age': [25, 24, 1]})
if "names_active" not in st.session_state:
st.session_state["names_active"] = list(df['Name'])
st.markdown(st.session_state["names_active"])
return_df = AgGrid(data = df, data_return_mode = 'FILTERED')
st.session_state["names_active"] = list(return_df['data']['Name'])
st.markdown(st.session_state["names_active"])
It may seem a random question but it’s just an example that will solve my problem. Any help would be appreciated! Thanksss!