Skip to content

Action buttons

Add clickable buttons to a row or a column header — an Edit / Drill / Delete affordance — that report back to your callback instead of doing anything themselves. In Dash this is a dedicated action column (and per-header headerActions) whose clicks set the action_triggered prop with the decoded row and path; in the adapters you build the same with a custom cellRenderers button wired to your own handler.

This is best seen in a running app; the code is the whole feature:

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"]
cols = engine.make_column_defs(ROWS, {"revenue": "sum"})
cols.append(engine.make_action_column(
actions=[
{"id": "edit", "label": "Edit", "icon": "edit"}, # built-in icon name…
{"id": "drill", "label": "Drill", "iconSvg": "<svg …>…</svg>"}, # …or raw SVG (set allow_html)
],
header="Actions",
))
grid = TensorGrid(id="grid", row_data=engine.get_tree_payload(ROWS, {"revenue": "sum"}), column_defs=cols)
@callback(Output("log", "children"), Input("grid", "action_triggered"), prevent_initial_call=True)
def on_action(a):
# Row action: {row_id, action, n, row, path}; header action: {scope: 'column', column, action, n}
if a["action"] == "drill":
return engine.drill_through(ROWS, a["path"], limit=3)
return f"{a['action']} on {a['row_id']}"
  • Action items are {id, label?, icon?, iconSvg?, title?}. icon accepts a built-in name (edit, delete, view, search, download, info, filter, more, plus, check, refresh, star); iconSvg takes a raw SVG string.
  • Header actions. headerActions: [{id, icon, label, title}] on a column def adds buttons to the header; a click fires action_triggered with scope: 'column' and the column id.
  • allow_html. With the default (safe) setting Dash sanitizes iconSvg (strips scripts / handlers); set allow_html=True only for fully trusted, developer-controlled SVG. In the vanilla adapter a cellRenderers return is inserted verbatim, so escape interpolated data with htmlEscape.
  • The decoded path on a row action goes straight into drill_through; see the full events surface.