Zum Hauptinhalt springen
VelinStyle v1.2.0
⌂ Home
  1. Docs
  2. Erste Schritte
  3. Datentabelle

Datentabelle 1.2.0

The <velin-data-Tabelle> Web Komponente enhances a plain <Tabelle> with Sortierung, Filterung and pagination. The markup stays semantic, so the Tabelle is fully readable before the Komponente upgrades and with JavaScript disabled. English: Data Table

Reifegrad: Dokumentiert als stabil in VelinStyle 1.2.0. Design Intelligence (Plan / Review / Agent-Meta) ist separat und Beta / Grundlage wo entsprechend angegeben.

Wann verwenden

Wann nicht verwenden

Grundlagen

Wrap an ordinary Tabelle. Add sortable to make every column sortable, or opt in per column with data-sort.

Teammitglieder
Name Commits Beigetreten Rolle
Ada Lovelace4122023-01-15Engineering
Grace Hopper12802022-06-02Engineering
Alan Turing962024-03-01Research
Katherine Johnson7342021-11-20Research
Radia Perlman582025-07-09Networking
<velin-data-table filter-input="#dtFilter" page-size="3">
  <table class="velin-table">
    <caption>Team members</caption>
    <thead>
      <tr>
        <th data-sort="text">Name</th>
        <th data-sort="number">Commits</th>
        <th data-sort="date">Joined</th>
        <th data-sort="none">Role</th>
      </tr>
    </thead>
    <tbody>…</tbody>
  </table>
</velin-data-table>

The Tabelle needs an accessible name. Provide a <caption>, an aria-label, or a label attribute on the host — the Komponente warns in the console if all three are missing.

Sortierung

Each sortable header is replaced with a real <Button>, so Sortierung works with the Tastatur and is announced as a Button by Screenreader. The aktuell state lives on the <th> as aria-sort, and only one column is sorted at a time. Activating the same column again reverses the direction.

data-sortVergleich
textGro?-/Kleinschreibung ignorierender String-Vergleich (Standard with sortable)
numberParsed as a number, so 9 sorts before 30
dateParsed with Date.parse
noneSpalte ist nicht sortierbar und erh?lt keinen Button

To sort by something other than the sichtbar text — a raw timestamp behind a formatted date, for example — put the comparable value in data-sort-value on the cell.

<td data-sort-value="1700000000">15 Nov 2023</td>

Filterung

Point filter-input at any existing input; typing filters rows on a debounced substring match. Non-matching rows get the verborgen attribute, which removes them from the layout and the accessibility tree rather than just hiding them visually.

By Standard the whole row is searched. Mark one or more cells with data-filter to restrict matching to those columns.

<td data-filter>Ada Lovelace</td>
<td>412</td>  <!-- ignored while filtering -->

Wenn nichts passt, wird eine einzelne Zeile mit empty-text über alle Spalten gerendert.

Paginierung

Set Seite-size to show a slice at a time. A labelled <nav> with Zurück and Weiter Buttons and a “Seite X of Y” status is appended; the edge Buttons are disabled rather than removed so Fokus is never lost. Paginierung is omitted entirely while everything fits on one Seite, and Filterung resets to Seite 1.

Attribut

AttributStandardHinweise
sortableMakes every column sortable as text unless data-sort says otherwise
filter-inputCSS selector of the input driving the filter
Seite-sizeZeilen pro Seite; weglassen für keine Paginierung
empty-textNo matching rowsWird angezeigt, wenn der Filter nichts findet
labelApplied as aria-label when the Tabelle has no caption
pagination-labelTabelle paginationZug?nglicher Name der Paginierungsnavigation
previous-text / next-textZurück / WeiterBeschriftungen der Paginierungsbuttons

JavaScript-API

const table = document.querySelector('velin-data-table');

table.sort(1, 'descending');   // column index, optional direction
table.filter('ada');           // same matching as the bound input
table.goToPage(2);             // clamped to the available pages

table.rows;          // every data row
table.matchingRows;  // rows passing the current filter
table.visibleRows;   // rows on the current page
table.page;          // current page number
table.pageCount;     // total pages for the current filter

Ereignisse

Barrierefreiheit

Vertragsstatus in core/a11y/Komponente-contracts.json: bestanden.