Alrighty, I think I finally get what you are looking for. 
This example uses the aggFunc
to calculate the summaries.
The callback is just something to get you started. It uses the cellClicked
prop to trigger the callback. It used the row id (included with the cellClicked
data) to get the row node.
from dash import Dash, html, clientside_callback, Input, Output
import dash_ag_grid as dag
import pandas as pd
app = Dash(__name__)
df = pd.read_csv(
"https://raw.githubusercontent.com/plotly/datasets/master/ag-grid/olympic-winners.csv"
)
columnDefs = [
{
"field": "country",
"rowGroup": True,
"hide": True,
"suppressColumnsToolPanel": True,
},
{
"field": "sport",
"rowGroup": True,
"hide": True,
"suppressColumnsToolPanel": True,
},
{
"field": "year",
"pivot": True,
"hide": True,
"suppressColumnsToolPanel": True,
},
{"field": "gold", "sortable": True, "filter": True, "aggFunc": "sum"},
{"field": "silver", "sortable": True, "filter": True, "aggFunc": "sum"},
{"field": "bronze", "sortable": True, "filter": True, "aggFunc": "sum"},
]
app.layout = html.Div(
[
dag.AgGrid(
id="grid",
enableEnterpriseModules=True,
columnDefs=columnDefs,
rowData=df.to_dict("records"),
defaultColDef={"resizable":True},
dashGridOptions={
"suppressAggFuncInHeader": True,
}
),
html.Div(id="output-container")
]
)
clientside_callback(
"""function (cellClicked) {
if (cellClicked) {
const api = dash_ag_grid.getApi("grid");
const node = api.getRowNode(cellClicked.rowId);
console.log("row", node)
return node.groupData["ag-Grid-AutoColumn"] + JSON.stringify(node.aggData)
}
return dash_clientside.no_update
}""",
Output("output-container", "children"),
Input("grid", "cellClicked"),
prevent_initial_call=True
)
if __name__ == "__main__":
app.run(debug=True)