Skip to content

DataTable

Render typed or pre-fetched rows as an accessible bounded data table.

Import from hedron import DataTable
Distribution hedron[data]
Backend activity No
Normal render mode RenderMode.FRAGMENT

Live demo

Team directoryCurrent workspace members
Employees
NameTeamStatus
AdaPlatformActive
GraceCompilerActive
AlanResearchLeave

Showing 3 employees.

The preview is a local docs simulation (not a running Hedron server). Interactive demos show a “Simulated HTMX” trace when applicable.

Install the optional provider before importing this component:

pip install "hedron[data]>=1.0.0"

Basic use

from hedron import DataTable
component = DataTable([{'id': '1', 'name': 'Ada'}], caption='Employees', page_size=25)

Compose under Page for full documents, or return from a fragment route for HTMX swaps.

How it works

DataTable normalizes mappings and models, resolves visible columns, redacts protected values, emits native table semantics, and exposes a CSV helper that omits hidden and secret columns. It does not fetch a source itself; fetch remote data first and pass a bounded DataPage.

This component's core behavior is server-rendered HTML and does not require a browser runtime. The preview is ordinary semantic HTML, so keyboard, form, link, and disclosure behavior comes from the platform.

Constructor and parameters

DataTable(rows=None, *, row_model=None, columns=None, page=None, query=None, caption=None, empty_message='No rows', page_size=25, allow_download=False)
Parameter Type Meaning
rows object Materialized mappings or model rows.
row_model type[Model] | None Typed column source.
columns Sequence[Column] | None Explicit column configuration.
page DataPage | None Pre-fetched bounded page with total and version metadata.
query DataQuery | None Query metadata associated with the rows.
caption str | None Accessible table name.
empty_message str Text spanning the empty table body.
page_size int Page-size metadata.
allow_download bool Expose download intent to the owning application.

Composition and backend behavior

Keep DataTable at the smallest semantic boundary. Fragment routes should return only the replaced region and preserve stable target IDs across success, validation, empty, loading, and error responses.

DataTable renders data the server already prepared. Keep queries, authorization, and redaction on the route or data source — do not treat the component as a place for side effects.

Accessibility

Use a precise caption, human column labels, and text equivalents for status or icon cells.

Security

Escaping and SafeUrl / TrustedHtml are framework concerns; authorization and data exposure remain application code. Redact secrets before rendering.

Common mistakes

  • Do not render an unbounded query or assume allow_download creates an authorized download route.
  • Do not copy docs-preview JavaScript into an application server.

Testing

from hedron import RenderMode, render

result = render(component, mode=RenderMode.FRAGMENT)
assert result.html
assert not result.diagnostics

All component demos · Built-in API · Testing