Datatable

A native keyed table with server sorting, search and pagination reflected into a shareable URL.

Click a column to sort; click it again to reverse the applied direction.

Open in new tab

Each preview is its own Live page in a frame, because this site is a Vue 3.5 app built on the Pulsar starter kit. An open list or popover stays inside its frame; in your application it opens over the page.

Installation

bash
suprnova live:add datatable

Usage

html
{% import "suprnova-ui/datatable/datatable.html" as datatable %}
{% call datatable::datatable("invoices", "Invoices", 0) %}{% call datatable::datatable_body() %}<tr><td>No invoices.</td></tr>{% endcall %}{% endcall %}

Examples

Search and empty results

The server searches demo invoices and keeps a native empty row when nothing matches.

Open in new tab

Paged results

Sort, search and page through fourteen invoices; the preview URL reproduces the state.

Open in new tab

Keyboard and accessibility

suprnova.datatable - a native table whose sort, filter and page state the island reflects into the URL (DATA-005). The column macro takes the applied sort key and the direction word (ascending or descending), which the island holds, so the view stays under the checker's branch limit. The sort and filter inputs bind the island's `sort` and `filter` model fields through `live:model`, which the runtime proposes on submit; the submit carries `prevent`, so the form never also submits natively. Sort and filter are Live submits on the island's model fields; the reflected query is shareable and the document mounts the table from it. Rows render inside a loop, so keys pass through live_key; the island exposes `pub mod filters { pub use suprnova::view::filters::live_key; }`.

API reference

datatable

ParameterDefaultDescription
idRequiredThe unique native table id.
captionRequiredThe table caption describing the rows.
countRequiredThe matching row count across all pages.

datatable_head

No parameters.

datatable_column

ParameterDefaultDescription
keyRequiredThe column key proposed to the sort model field.
textRequiredThe visible sort button label.
sortRequiredThe applied sort column; a match adds aria-sort.
directionRequiredThe applied aria-sort word: ascending or descending.
action"sort"The server action submitted by the sort form.

datatable_heading

ParameterDefaultDescription
textRequiredThe text of a column header without a sort action.

datatable_body

No parameters.

datatable_row

ParameterDefaultDescription
keyRequiredThe stable row domain key, encoded through live_key.

datatable_row_heading

ParameterDefaultDescription
textRequiredThe row header text, rendered with scope=row.

datatable_cell

ParameterDefaultDescription
textRequiredThe displayed cell value.
numericfalseWhether to align the cell as a numeric value.

datatable_filter

ParameterDefaultDescription
tableRequiredThe table id used to derive the unique filter input id.
labelRequiredThe search region and input label.
valueRequiredThe current filter model value.
action"filter"The server action submitted by the search form.