Skip to content

Drill-through

Every grid cell is an aggregate; drill-through answers “which rows made this number?” Given a group-key path, the engine returns the underlying source rows that rolled up into that node — the exact records behind the subtotal, optionally column-projected and row-limited. It’s the same Polars filter the aggregation used, so the answer is always consistent with the displayed value.

from dash import Input, Output, callback
from dash_tensor_grid import TensorGrid
from dash_tensor_grid.engine import GridDataEngine
engine = GridDataEngine(sales)
ROWS = ["region", "country"]
# Fire `cell_clicked` (enable_cell_click) and read its decoded group-key `path`.
grid = TensorGrid(id="grid", enable_cell_click=True, row_data=..., column_defs=...)
@callback(Output("detail", "children"), Input("grid", "cell_clicked"), prevent_initial_call=True)
def show_source(cell):
path = cell["path"] # e.g. ["EMEA", "Germany"]
rows = engine.drill_through(ROWS, path, limit=100)
return f"{len(rows)} source rows: {rows}"
  • Path-addressed. Drill-through takes the group-key path (["EMEA", "Germany"]) — exactly the path the Dash cell_clicked event decodes, so you hand it straight to engine.drill_through.
  • limit and column projection. Cap the returned rows and select which source columns to bring back; the result is JSON-safe (NaN/Inf/None normalised).
  • Same rows, two surfaces. Master / detail renders the drilled rows inline; selection copies/exports the drilled rows behind the selected nodes.