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, callbackfrom dash_tensor_grid import TensorGridfrom 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}"import { TensorGrid } from '@tensorgrid/react';import { drillThrough } from '@tensorgrid/core';
// `masterDetail` reveals the source rows inline (it calls drillThrough under the hood):<TensorGrid data={data} rows={['region', 'country']} measures={{ revenue: 'sum' }} masterDetail />;
// …or call the pure helper headlessly for your own panel/export:const rows = drillThrough(data, ['region', 'country'], ['EMEA', 'Germany'], { limit: 100 });<TensorGrid :data="data" :rows="['region', 'country']" :measures="{ revenue: 'sum' }" master-detail/>import { mountTensorGrid } from '@tensorgrid/vanilla';import { drillThrough } from '@tensorgrid/core';
mountTensorGrid(document.getElementById('grid'), { data, rows: ['region', 'country'], measures: { revenue: 'sum' }, masterDetail: true,});
// Headless retrieval of the rows behind a node:const rows = drillThrough(data, ['region', 'country'], ['EMEA', 'Germany'], { limit: 100 });- Path-addressed. Drill-through takes the group-key path (
["EMEA", "Germany"]) — exactly thepaththe Dashcell_clickedevent decodes, so you hand it straight toengine.drill_through. limitand 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.