How to get Aggrid cell value by mouse clicking in streamlit

I have reviewed my code, and it functions correctly, providing a complete tree structure using Aggrid. However, I require assistance in obtaining the value of a selected cell through mouse clicks. Could you please guide me on how to retrieve the selected cell value and provide the appropriate code? Thank you.

import pandas as pd
import streamlit as st
from st_aggrid import JsCode, AgGrid, GridOptionsBuilder

df=pd.DataFrame([{“orgHierarchy”: ‘A’, “jobTitle”: “CEO”, “employmentType”: “Permanent” },
{ “orgHierarchy”: ‘A/B’, “jobTitle”: “VP”, “employmentType”: “Permanent” },
{ “orgHierarchy”: ‘A/B/A’, “jobTitle”: “VP”, “employmentType”: “Permanent” },
{ “orgHierarchy”: ‘A/C’, “jobTitle”: “Manager”, “employmentType”: “Permanent” }])
st.write(df)
gb = GridOptionsBuilder.from_dataframe(df)
gridOptions = gb.build()

gridOptions[“columnDefs”]= [
{ “field”: ‘jobTitle’ },
{ “field”: ‘employmentType’ },
]
gridOptions[“defaultColDef”]={
“flex”: 1,
},
gridOptions[“autoGroupColumnDef”]= {
“headerName”: ‘Organisation Hierarchy’,
“minWidth”: 300,
“cellRendererParams”: {
“suppressCount”: True,
},
},

gridOptions[“treeData”]=True
gridOptions[“animateRows”]=True
gridOptions[“groupDefaultExpanded”]= -1
gridOptions[“getDataPath”]=JsCode(“”" function(data){
return data.orgHierarchy.split(“/”);
}“”").js_code

r = AgGrid(
df,
gridOptions=gridOptions,
height=500,
allow_unsafe_jscode=True,
enable_enterprise_modules=True,
filter=True,
#update_mode=GridUpdateMode.SELECTION_CHANGED,
theme=“material”,
tree_data=True
)

st.write(r)

Hi @mfahim204s8!

I suggest posting in [https://discuss.streamlit.io/t/ag-grid-component-with-input-support](this thread) to get more attention. However, you should be able to find focussedCell (or something like that - I’ll have to check later) if you print the main response of the grid object. I tried with the actual “selection” based methods but this was the only one that I could get to work. For sure worth getting more opinion on the other thread, but maybe you can find this parameter in the meantime!