Hello all,
I am trying to implement a aggrid table where the entry in Value column will be based on the type selected in Type column.
Type column can be constant or transient. If constant, the Value column should be editable and if transient, the Value column should show a drop-down list where I select a pre-loaded file.
I have got to a point where I can create the table and have editable columns. But they don’t depend on each other. They work like independent cells. Is there a way to implement what I mentioned?
When I select Constant in Type, I should be able to enter 5 in the Value column. But right now when I click on 0 in the value column to change, it automatically invokes the drop-down menu. Is there a way here?
st.session_state.dataframe = pd.DataFrame.from_dict(st.session_state.inputs)
type_dropdownlist = ('Constant', 'Transient')
datasets_dropdownlist = tuple(dataset_names)
gb = GridOptionsBuilder.from_dataframe(st.session_state.dataframe)
gb.configure_default_column(editable=True, min_column_width=10)
gb.configure_column('Type', editable=True, cellEditor='agSelectCellEditor',
cellEditorParams={'values': type_dropdownlist}, singleClickEdit=True)
gb.configure_column('Value', editable=True, cellEditor='agSelectCellEditor',
cellEditorParams={'values': datasets_dropdownlist}, singleClickEdit=True)
gb.configure_column('Input Name', editable=False)
grid_options = gb.build()
grid_height = 250
grid_response = AgGrid(
st.session_state.dataframe,
gridOptions=grid_options,
height=grid_height,
width='100%',
data_return_mode=DataReturnMode.FILTERED_AND_SORTED,
update_mode=GridUpdateMode.VALUE_CHANGED
)
df = grid_response['data']