This code functions flawlessly and successfully generates the tree I require without any errors. However, I would like to retrieve the cell value by clicking the mouse, specifically obtaining the row number, index ID, and cell value. I would appreciate your guidance and the appropriate code to achieve this. Thank you in advance for your assistance.
see my code
import streamlit as st
from st_aggrid import AgGrid , GridOptionsBuilder
import pandas as pd
Convert company data structure to DataFrame
data = [
{ “company” : “Company A” , “hq” : “HQ 1” , “team” : “Team 1-1” , “part” : “Part 1-1” },
{ “company” : “Company A” , “hq” : “HQ 1” , “team” : “Team 1-1” , “part” : “Part 1-2” },
{ “company” : “Company A” , “hq” : “HQ 1” , “team” : “Team 1-1” , “part” : “Part 1-3” },
{ “company” : “Company A” , “hq” : “HQ 1” , “team” : “Team 1-2” , “part” : “Part 2-1” },
{ “company” : “Company A” , “hq” : “HQ 1” , “team” : “Team 1-3” , “part” : “Part 2-2” },
{ “company” : “Company A” , “hq” : “HQ 2” , “team” : “Team 2-1” , “part” : “Part 2-3” },
{ “company” : “Company A” , “hq” : “HQ 2” , “team” : “Team 2-2” , “part” : “Part 3-1” },
{ “company” : “Company B” , “hq” : “HQ 3” , “team” : “Team 3-1” , “part” : “Part 3-2” },
{ “company” : “Company B” , “hq” : “HQ 3” , “team” : “Team 3-2” , “part” : “Part 3-3” },
{ “company” : “Company B” , “hq” : “HQ 4” , “team” : “Team 4-1” , “part” : “Part 4-1” },
{ “company” : “Company B” , “hq” : “HQ 4” , “team” : “Team 4-2” , “part” : “Part 4-2” },
{ “company” : “Company B” , “hq” : “HQ 4” , “team” : “Team 4-3” , “part” : “Part 4-3” },
]
df = pd . DataFrame ( data )
Ag-Grid settings
gb = GridOptionsBuilder . from_dataframe ( df )
gb . configure_default_column ( groupable = True )
gb . configure_column ( “company” , rowGroup = True , hide = True )
gb . configure_column ( “hq” , rowGroup = True , hide = True )
gb . configure_column ( “team” , rowGroup = True , hide = True )
#gb.configure_column(“part”, rowGroup=True, hide=True)
gb . configure_column ( “part” , header_name = “Team” , min_width = 250 )
gridOptions = gb . build ()
st . header ( “Company Structure” )
AgGrid ( df , gridOptions = gridOptions , enable_enterprise_modules = True )