Selection & range
Ctrl/Cmd-click a row to toggle its selection; shift-click extends a contiguous range. The opt-in status bar summarizes the selection (count and per-measure sum / avg / min / max over the underlying source rows), and Ctrl/Cmd-C or the export button emits those source rows as CSV. The summary is computed by the engine over the real rows behind the selected nodes — the frontend does no math.
from dash import Input, Output, callbackfrom dash_tensor_grid import TensorGrid
# `selected_rows` is read-only output; `enable_range_selection` turns on marquee/block selection,# and Ctrl/Cmd-C reports `clipboard_copy`. Drive an export from a callback via the `command` prop.grid = TensorGrid(id="grid", row_data=..., column_defs=..., enable_range_selection=True)
@callback(Output("count", "children"), Input("grid", "selected_rows"), prevent_initial_call=True)def on_select(rows): return f"{len(rows or [])} selected"import { TensorGrid } from '@tensorgrid/react';
<TensorGrid data={data} rows={['region', 'country']} measures={{ revenue: 'sum', qty: 'sum' }} showStatusBar // count + per-measure sum/avg/min/max of the selection showExportButton exportMode="source" // emit the selected SOURCE rows (or all if none selected) enableClipboard // Ctrl/Cmd-C copies the selected source rows as CSV onSelectionChange={(ids) => console.log('selected', ids)}/>;<TensorGrid :data="data" :rows="['region', 'country']" :measures="{ revenue: 'sum', qty: 'sum' }" show-status-bar show-export-button export-mode="source" enable-clipboard @selection-change="(ids) => console.log('selected', ids)"/>import { mountTensorGrid } from '@tensorgrid/vanilla';
const grid = mountTensorGrid(document.getElementById('grid'), { data, rows: ['region', 'country'], measures: { revenue: 'sum', qty: 'sum' }, showStatusBar: true, showExportButton: true, enableClipboard: true,});
grid.getSelected(); // selected node ids (pull-model)grid.selectionToCsv(); // CSV of the source rows under the selection- Selecting a group selects its rows. A selected node resolves to the source rows beneath it, so the summary and export cover the whole subtree — synthetic nodes (grand total, “Others”) contribute nothing.
- Range aggregation.
showStatusBarruns the engine’ssummarizeRowsover the selected source rows; there’s no client-side re-summation of pre-aggregated leaves (which would give mean-of-means). - Copy / export the source, not the display.
enableClipboardandexportMode: 'source'emit the raw underlying rows; useexportMode: 'aggregated'for the rolled-up view as shown. See export & scale.