here a simple example of the problem
import streamlit as st
@st.cache_data
def load_data():
initial_data = {‘item’: {‘Fd1’: ‘item 1’, ‘Fd2’: ‘item 1’, ‘Fd3’: ‘item 1’, ‘Fd4’: ‘item 1’, ‘Fd5’: ‘item 1’, ‘Fd6’: ‘item 1’, ‘Fd7’: ‘item 1’},
‘Name’: {‘Fd1’: ‘info 1’, ‘Fd2’: ‘info 1’, ‘Fd3’: ‘info 1’, ‘Fd4’: ‘info 1’, ‘Fd5’: ‘info 1’, ‘Fd6’: ‘info 1’, ‘Fd7’: ‘info 1’},
‘Data 1’: {‘Fd1’: 10, ‘Fd2’: 25, ‘Fd3’: 22, ‘Fd4’: 15, ‘Fd5’: 30, ‘Fd6’: 24, ‘Fd7’: 8},
‘Data 2’: {‘Fd1’: 2.5, ‘Fd2’: 3.0, ‘Fd3’: 4.0, ‘Fd4’: 4.2, ‘Fd5’: 3.0, ‘Fd6’: 1.8, ‘Fd7’: 0.8},
‘Data 3’: {‘Fd1’: .35, ‘Fd2’: 0.4, ‘Fd3’: 0.42, ‘Fd4’: 0.5, ‘Fd5’: 0.5, ‘Fd6’: 0.3, ‘Fd7’: 0.2}}
return initial_data
st.set_page_config(layout=“wide”,page_title=“Test Case”)
if ‘Fd_data’ not in st.session_state:
initial_data = load_data()
st.session_state[‘Fd_data’] = initial_data
tab1, tab2, tab3 = st.tabs([“Feed Data”, “Operating Data”, “Calibration Ylds”])
with tab1:
col1, col2, col3 = st.columns([4, 1, 4])
c1 = col1.container(border=True)
c2 = col2.container(border=True)
c3 = col3.container(border=True)
fd_sel = c1.radio('Select cases',['Select Item A', 'Select Item B', 'Select Item C'],
horizontal=True, label_visibility="collapsed")
if fd_sel == 'Select Item A':
edit_list = ('Name','Data 1','Data 2')
if fd_sel == 'Select Item B':
edit_list = ('Name','Data 2','Data 3')
if fd_sel == 'Select Item C':
edit_list = ('Data 1','Data 2','Data 3')
# using the "column_order=edit_list" as show below does not work correctly
data_dic = c1.data_editor(st.session_state['Fd_data'],column_order=edit_list, hide_index=True )
# with out the column_order=edit_list this works well
data_dic = c1.data_editor(st.session_state['Fd_data'], hide_index=True )