Trigger function from an st.data_editor

im running a local streamlit app.

on user action (be it a click or, preferably, a selection) of a row/cell
i would like to show content of a json file to st.json below the table.

import streamlit as st
import pandas as pd

# sample DataFrame
data = {
    "Column 1": [1, 2],
    "Column 2": ['A', 'B']
}

#sample json
jdata ='''
    {
        "glossary": {
            "title": "example glossary",
        }
    }
'''

# Create a DataFrame from the sample data  
df = pd.DataFrame(data)

# Display the DataFrame in the Streamlit app
st.dataframe(df,
        column_config={
            "json": st.column_config.LinkColumn(
            "JSON",
            width='small',
            )
        }
)

#only show the following on click of row/cell
st.json(jdata)

Hi @yoshco

If you’d like to use the st.data_editor, you can replace st.dataframe with st.data_editor.

In order to trigger a function upon widget interaction or changes to the dataframe, you can make use of the on_change parameter by assigning it a callback function that essentially will tell it what to do once the trigger occurs.

More info on st.data_editor in the Docs:

More info on Session states also in the Docs:

thank you for the links, mybe i’ll rephrase my question as i dont see the solution in those links. |
how do i retrun on callback the specific cell/row i clicked?