I want to implement below, but failed:
1 pass a selected value from a parent control to a child control. The child control UI displays the new value
2 changing the child control value doesn’t affect parent control.
Below is what I did, but it is not working in that parent control create a new child control every time, yet not passing value to the existing child control.
import streamlit as st
@st.fragment
def create_dd():
# with st.container():
data = []
with st.container():
options = st.multiselect(
"Parent list",
["a", "b", "c",],
data
, key='ms_1'
)
st.session_state.dd = options
st.write("Parent selected:", options)
if options:
create_dd2()
@st.fragment
def create_dd2():
data = []
if 'dd' in st.session_state:
data = st.session_state.dd
with st.container():
options2 = st.multiselect(
"Child list",
["a", "b", "c"],
data
,key='ms_2'
)
st.write("Child selected:", options2)
create_dd()
create_dd2()
any idea?