Skip to content

Tables & Data Grids ​

The most-used component in any admin panel, and the one most templates get wrong.


Base table ​

html
<div class="av-table-wrap">
  <table class="av-table av-table--hover">
    <caption class="av-visually-hidden">Orders, 25 of 1,284 shown</caption>
    <thead>
      <tr>
        <th scope="col">Order</th>
        <th scope="col">Customer</th>
        <th scope="col">Status</th>
        <th scope="col" class="av-table__num">Total</th>
        <th scope="col">Date</th>
        <th scope="col" class="av-table__actions-cell"><span class="av-visually-hidden">Actions</span></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <th scope="row"><a href="/orders/1042">#1042</a></th>
        <td>
          <span class="av-table__person">
            <img class="av-avatar av-avatar--sm" aria-hidden="true">
            <div>
              <span class="av-table__link">Mark Ellis</span><br>
              <span class="av-table__person-meta">mark@acme.io</span>
            </div>
          </div>
        </td>
        <td><span class="av-badge av-badge--success-soft">
          <svg class="av-icon av-icon--sm" aria-hidden="true" viewBox="0 0 24 24"><path d="M4 12.5l5 5 11-11"/></svg>
          Paid
        </span></td>
        <td class="av-table__num">€248.00</td>
        <td><time datetime="2026-08-11T14:22">11 Aug 2026</time></td>
        <td class="av-table__actions-cell">…</td>
      </tr>
    </tbody>
  </table>
</div>

Semantics that matter ​

DetailWhy
<caption> (visually hidden)Screen readers announce the table's purpose and size
scope="col" on header cellsAssociates columns with data
<th scope="row"> on the identifying cellScreen readers announce "Order 1042" as context for every other cell in the row
<time datetime>Machine-readable date; enables correct sorting and locale display
av-table__num on numeric cellsRight-aligned tabular figures are scannable
av-visually-hidden header for the actions columnAn empty <th> is an accessibility error
Status badge has an icon and text, not just colourWCAG 1.4.1
av-btn--sm on the row-action controlThe step the button scale documents for table rows. Three list pages once set --av-btn-height: 30px inline instead, so the same menu button shipped at two sizes across nine otherwise identical pages — and the inline styles were the reason nothing could see it.

Variants ​

html
<table class="av-table av-table--hover">      <!-- row hover -->
<table class="av-table av-table--striped">    <!-- zebra -->
<table class="av-table av-table--bordered">   <!-- all borders -->
<table class="av-table">      <!-- no outer border, for inside a card -->
<table class="av-table av-table--sticky-head">
<table class="av-table av-table--sticky-col">
<table class="av-table">    <!-- overrides density locally -->
scss
@layer components {
  .av-table {
    --av-table-cell-padding-x:  var(--av-space-4);
    --av-table-cell-padding-y:  var(--av-space-3);
    --av-table-header-bg:       var(--av-surface-sunken);
    --av-table-header-color:    var(--av-text-muted);
    --av-table-border-color:    var(--av-border-subtle);
    --av-table-row-hover-bg:    var(--av-surface-sunken);
    --av-table-row-selected-bg: var(--av-surface-accent-subtle);

    inline-size: 100%;
    border-collapse: separate;      /* required for sticky headers to keep borders */
    border-spacing: 0;

    th, td {
      padding: var(--av-table-cell-padding-y) var(--av-table-cell-padding-x);
      border-block-end: 1px solid var(--av-table-border-color);
      text-align: start;
    }

    thead th {
      background: var(--av-table-header-bg);
      color: var(--av-table-header-color);
      font-size: var(--av-font-size-xs);
      font-weight: var(--av-font-weight-semibold);
      text-transform: uppercase;
      letter-spacing: var(--av-tracking-wide);
      white-space: nowrap;
    }

    tbody tr:last-child td { border-block-end: 0; }

    td { font-variant-numeric: tabular-nums; }
  }

  .av-table--sticky-head thead th {
    position: sticky;
    inset-block-start: 0;
    z-index: var(--av-z-sticky);
  }

  .av-table--sticky-col {
    th:first-child, td:first-child {
      position: sticky;
      inset-inline-start: 0;
      background: var(--av-surface-raised);
      z-index: 1;
    }
    thead th:first-child { z-index: calc(var(--av-z-sticky) + 1); }
  }

  @media (hover: hover) {
    .av-table--hover tbody tr:hover { background: var(--av-table-row-hover-bg); }
  }
}

border-collapse: separate is required — with collapse, sticky headers lose their bottom border in every browser.


Data grid ​

Progressive enhancement over a server-rendered table. Everything is an attribute: the table stays sortable, searchable, filterable and paginated without a line of configuration JavaScript.

html
<div class="av-card av-card--flush-body" data-av-datagrid
     data-av-grid-id="customers" data-av-grid-noun="customer" data-av-grid-per-page="10">

  <div class="av-toolbar">
    <label class="av-toolbar__search">
      <input type="search" name="q" placeholder="Name or company…" data-av-grid-search
             aria-label="Search customers">
    </label>
    <span class="av-toolbar__count" data-av-grid-count aria-live="polite"></span>
  </div>

  <div class="av-table-wrap">
    <table class="av-table av-table--hover">
      <caption class="av-visually-hidden">Customers, filterable and sortable</caption>
      <thead>
        <tr>
          <th scope="col"><button class="av-table__sort" type="button" data-av-sort="name">Customer</button></th>
          <th scope="col" class="av-table__num"><button class="av-table__sort" type="button" data-av-sort="lifetime">Lifetime</button></th>
        </tr>
      </thead>
      <tbody>
        <tr data-av-status="vip">
          <th scope="row" data-av-key="name" data-av-value="Sarah Kim">Sarah Kim</th>
          <td class="av-table__num" data-av-key="lifetime" data-av-value="1240">€1,240.00</td>
        </tr>
      </tbody>
    </table>
  </div>

  <div class="av-empty" data-av-grid-empty hidden>…</div>
  <div class="av-pagination">
    <span class="av-pagination__info" data-av-grid-info></span>
    <nav class="av-pagination__pages" data-av-grid-pages aria-label="Pagination"></nav>
  </div>
</div>

The grid reads the existing rows, upgrades them in place, and never blanks the screen. Sorting and filtering compare data-av-value, never the rendered text — €1,240.00 and 1240 do not sort the same way. The grid works on the rows already in the page; it does not fetch.

Markup hooks ​

This is the contract the shipped zero-build grid reads. Everything is an attribute, so a table stays sortable and filterable without a line of configuration JavaScript.

AttributeOnPurpose
data-av-datagridwrapperClaims the table for the built-in grid
data-av-grid-idwrapperNamespaces the saved views in localStorage
data-av-grid-nounwrapperThe singular noun for every count, confirm and toast
data-av-grid-noun-pluralwrapperOnly for an irregular plural; defaults to the noun plus s
data-av-grid-per-pagewrapperPage size (default 8)
data-av-grid-searchinputGlobal search over the row text
data-av-grid-filterbuttonA segment chip; all clears it
data-av-sortbutton in a thSorts on that column's key
data-av-key / data-av-valuetd / thThe column key, and the comparable value
data-av-grid-select-all / -row-checkinputSelection
data-av-grid-bulk / -bulk-count / -bulk-clear / -bulk-deletebulk barThe selection bar
data-av-grid-bulk-verb / -bulk-done / -bulk-text / -bulk-cancelthe bulk buttonThe words the confirmation uses; default Delete / deleted / the permanent-removal sentence / Keep them
data-av-grid-bulk-switcha button in the bulk baron or off: sets each selected row's switch instead of removing the row
data-av-grid-row-switchthe row's checkbox switchThe switch a bulk on/off button sets
data-av-grid-count / -info / -pages / -emptyanywhere insideResult count, range, pager, empty state

Declare the noun. Every sentence the grid produces — the toolbar count, the delete confirmation, the toast after it — is built from data-av-grid-noun. It used to be hard-coded to order, because orders is the table the module was written against, so the products grid reported "12 orders" from the day it shipped. Nothing looked wrong: the number was right, the row count was right, and the only thing that was false was the word. Undeclared, the grid falls back to row, which is honest rather than confidently wrong.

Declare the verb too, if the button is not a delete. data-av-grid-bulk-delete removes the selected rows from the table, and it used to hard-code "Delete" into the confirmation behind that button whatever the button itself said. Two shipped pages already disagreed with it out loud: the products grid is labelled Archive selected and the ticket queue Close selected, and both opened a dialog reading "Delete 3 products? This permanently removes them and their history." The button was honest and the dialog was not, which is the dead-control defect inverted — and no gate could see it, because the attribute is present, the listener runs, nothing throws, and no suite reads the copy.

html
<button class="av-btn av-btn--sm av-btn--soft-danger" type="button"
        data-av-grid-bulk-delete
        data-av-grid-bulk-verb="Archive"
        data-av-grid-bulk-done="archived"
        data-av-grid-bulk-text="They come off the storefront and out of this list."
        data-av-grid-bulk-cancel="Keep them listed">
  Archive selected
</button>

What is not configurable is the row leaving the table: that is what this hook does, and a verb implying otherwise — Suspend, on a list that also has a Suspended filter — means the wrong hook was picked, not the wrong word.

A segment chip carries its own count. .av-filter-chip__count inside a [data-av-grid-filter] button puts the number in the control that applies it, rather than in a stat card above the table that reports a figure the grid then ignores. Two consequences, and both are the reason to do it that way: the count can never disagree with the list, because pressing it is what produced the list; and the top of a list page becomes navigation instead of decoration. The printed number is still markup with a second writer, so npm run check:facets holds it to the rows carrying that data-av-status.

html
<button class="av-filter-chip" type="button" data-av-grid-filter="at-risk" aria-pressed="false">
  At risk
  <span class="av-filter-chip__count">3</span>
</button>

Cards are for a profile, not for a base. .av-customer-card is the right component for one record you have already found; it is the wrong one for finding it. A card grid over 2,481 customers shows six of them and answers no question an admin opens the screen to ask — who has gone quiet, who is worth keeping, who ordered last week. That is a table with segments, sorting, a filter builder and an export, and it is what html/pages/apps/customers.html is built from.

Large and server-backed data ​

The built-in grid does not fetch: it sorts, filters and pages the rows in the document. For a large dataset, either render one page on the server and handle paging with ordinary links, use virtual scrolling, or opt in to Tabulator with data-av-datagrid-library="tabulator" — see Data Grids.


Sorting ​

html
<th scope="col">
  <button class="av-table__sort" type="button" data-av-sort="created_at">Date</button>
</th>

Pressing the button sorts on that column's data-av-values and toggles direction. The runtime puts aria-sort="ascending" or "descending" on the sorted <th> and removes it from the others.

aria-sort on the <th> is the standard. A sort icon alone tells a screen-reader user nothing.

The sort control is a <button> inside the <th> — making the <th> itself clickable is not keyboard-accessible.


Row selection ​

html
<thead>
  <tr>
    <th scope="col" class="av-table__check">
      <input class="av-check" type="checkbox"
             data-av-grid-select-all
             aria-label="Select all rows on this page">
    </th>
    …
  </tr>
</thead>
<tbody>
  <tr>
    <td class="av-table__check">
      <input class="av-check" type="checkbox"
             data-av-grid-row-check value="1042"
             aria-label="Select order 1042">
    </td>
    …
  </tr>
</tbody>

Bulk action bar ​

html
<div class="av-bulkbar" data-av-grid-bulk>
  <span class="av-bulkbar__count" data-av-grid-bulk-count>0 selected</span>
  <button class="av-btn av-btn--sm av-btn--quiet" type="button">Export selected</button>
  <button class="av-btn av-btn--sm av-btn--soft-danger" type="button" data-av-grid-bulk-delete>Delete</button>
  <button class="av-btn av-btn--sm av-btn--ghost" type="button" data-av-grid-bulk-clear>Clear selection</button>
</div>

The bar shows (is-active) while any row is checked and its count follows the selection. data-av-grid-bulk-delete asks for confirmation, then removes the selected rows; any other button in the bar is yours to wire. The header checkbox goes indeterminate when some, but not all, visible rows are selected.

Bulk on and off ​

Some bulk actions change a state rather than remove a row: turning five connectors off, pausing three schedules. data-av-grid-bulk-switch="on" or ="off" sets the [data-av-grid-row-switch] in every selected row and fires change on each one it changes, so anything listening to a single switch hears the bulk action too. A switch marked aria-disabled="true" is left alone and counted, and the toast says how many were skipped. data-av-grid-bulk-done sets the word in that toast.

html
<div class="av-bulkbar" data-av-grid-bulk>
  <span class="av-bulkbar__count" data-av-grid-bulk-count>0 selected</span>
  <button class="av-btn av-btn--sm av-btn--quiet" type="button"
          data-av-grid-bulk-switch="on" data-av-grid-bulk-done="turned on">Turn on</button>
  <button class="av-btn av-btn--sm av-btn--quiet" type="button"
          data-av-grid-bulk-switch="off" data-av-grid-bulk-done="turned off">Turn off</button>
</div>

<!-- in each row -->
<label class="av-switch">
  <input type="checkbox" checked data-av-grid-row-switch name="on-github">
  <span class="av-visually-hidden">GitHub turned on</span>
</label>

The grid emits av:datagrid:switch with { el, on, changed, skipped } after each bulk change.


Expandable rows ​

html
<tr>
  <td class="av-table__expand">
    <button class="av-btn av-btn--ghost av-btn--icon av-btn--sm"
            data-av-row-expand="detail-1042"
            aria-expanded="false"
            aria-controls="detail-1042"
            aria-label="Show details for order 1042">
      <svg class="av-icon" aria-hidden="true" viewBox="0 0 24 24"><path d="M9 6l6 6-6 6"/></svg>
    </button>
  </td>
  …
</tr>
<tr class="av-table__detail" id="detail-1042" hidden>
  <td colspan="6">
    <div class="av-panel">
      <dl class="av-detail-list">
        <dt>Payment</dt><dd>Visa •••• 4242</dd>
        <dt>Shipping</dt><dd>DHL Express — IE12345678</dd>
      </dl>
      <table class="av-table">…line items…</table>
    </div>
  </td>
</tr>

Filters, saved views and export ​

A search box answers where is Sarah. It cannot answer orders over €500, from Halcyon, still unfulfilled — which is the question somebody opens an orders screen to ask. [data-av-grid-filters] is a panel of conditions over a [data-av-datagrid]; npm run test:grid-filters is its gate.

Declare which columns are filterable, and with what kind of value:

html
<th scope="col" data-av-filter="number" data-av-filter-key="total">
  <button class="av-table__sort" type="button" data-av-sort="total">Total</button>
</th>
TypeConditions offered
textcontains, does not contain, is, is not, is empty, is not empty
enumis, is not — with the values read off the rows
number=, ≠, >, <, between
dateon, before, after, between

Then point a panel at the grid. html/_partials/grid-filters-drawer.html is the shipped one; it is a drawer rather than a modal so the table stays on screen while a filter is being built.

html
<div data-av-grid-filters="#ordersGrid"
     data-av-grid-filter-badge="#avGridFilterCount"
     data-av-grid-export="[data-av-grid-export]">
  <div data-av-grid-filter-list></div>
  <button type="button" data-av-grid-filter-add>Add a filter</button>
  <button type="button" data-av-grid-filter-clear>Clear all</button>
  <div data-av-grid-views></div>
  <button type="button" data-av-grid-view-save>Save this view</button>
</div>

Seven decisions in it are worth knowing, because each is the difference between a filter panel and a picture of one.

The fields are declared; an enum's options are derived. Guessing "this column is a date" from its cells is right until the first empty one. But a hand-written option list beside a column agrees with the data on the day it is typed and silently stops — so the values come from the rows.

Comparison reads data-av-value, never the rendered text. A money cell reads €1,240.00 and holds 1240; "greater than 500" over the rendered string compares a currency symbol. This is the same contract the grid's own sort already depends on.

The state lives in the URL, and that is what makes it worth having. A filter panel whose state dies on refresh cannot be sent to a colleague and cannot be undone. It is the hash, not the query string, because these pages open from file:// and history.pushState on a file URL is a SecurityError in Chromium — the one environment this template guarantees.

A saved view stores the URL string, not the parsed filters. Storing objects means a migration the first time the grammar changes; storing the string means the parser is the only thing that has to stay compatible with what someone saved last year. Views are kept per grid id in localStorage.

Applying is not a button. The table moves as each control changes, the same call initFacets already made on the storefront: a filled Apply re-applies what is already applied, and the reader waits for it.

A number filter is type="text" with inputmode="decimal". A type="number" field edits itself when the wheel passes over it, and this panel lives in a scrolling drawer — so scrolling the filter list would silently change the filter and the table under it. .av-qty is text for the same reason.

Export writes what you are looking at, and neutralises formulas. The filtered, sorted set, from data-av-value, so the money column is a number a spreadsheet can sum. And every field beginning =, +, -, @, tab or CR is prefixed with an apostrophe: those are executed by Excel and Google Sheets the moment the file is opened, customer names are attacker-controlled in every real deployment, and an export button without this line ships the vulnerability to everyone who buys the template.

Every selector in the markup above is run through a guarded lookup. querySelector throws a SyntaxError on a malformed selector — including the empty string, which is what an absent optional attribute produces — and an uncaught throw there takes down every module the runtime initialises after this one. Both cases were live before the gate existed.


Importing a spreadsheet ​

[data-av-import] is the other half of the export button: choose a file, say which column is which, look at what will land, commit. npm run test:import is its gate.

html
<button class="av-btn av-btn--outline" type="button" data-av-modal-open="#avImport">Import</button>

<dialog class="av-dialog av-dialog--lg" id="avImport">
  <div class="av-dialog__inner"
       data-av-import
       data-av-import-target="#productsGrid"
       data-av-import-required="product,sku"
       data-av-import-max-rows="5000">
    <div data-av-wizard data-av-wizard-validate="false" data-av-wizard-deeplink="false">
      <!-- three [data-av-wizard-panel] sections; see
           html/_partials/import-dialog.html -->
      <div data-av-import-map></div>
      <div data-av-import-preview></div>
    </div>
  </div>
</dialog>

<template data-av-import-row-template>
  <tr data-av-status="draft">
    <th scope="row" data-av-key="product"></th>
    <td data-av-key="sku"></td>
  </tr>
</template>

The fields are the target table's own columns. They come from <th data-av-filter-key data-av-filter> — the same attributes the filter builder reads. Those attributes declare the column's data contract; a hand-written third copy beside the importer is the facet-count defect waiting to happen. data-av-import-required names which of them a row cannot omit.

Six things about it are decisions, and five of the failures they prevent produce a plausible table rather than an error — which is why an importer is worth a suite of its own.

A real parser, not split(','). Quoted fields containing commas, doubled quotes and embedded newlines are the entire reason CSV is harder than it looks. split handles none of them and does not throw: it silently produces a table with the wrong number of columns on exactly the rows that mattered — an address with a comma in it, a description with a line break — and every column after the split is shifted by one. The row still imports, into the wrong fields.

The delimiter is sniffed, not assumed. Half of Europe exports ; because their locale uses , as the decimal separator, and a parser that assumes a comma turns every one of those rows into a single column. It is counted outside quotes on the header line, because a comma inside a quoted header would otherwise win the vote.

Auto-mapping is proposed, never hidden. Matching a CSV header to a field by normalised name is right most of the time; hiding the rest is how prices get imported into the SKU column. The mapping step shows every field, pre-filled, with the first value from the chosen column beside it — "Total" and "Total inc. VAT" are the same word at a glance and different numbers in the file.

Numbers are read in both conventions. 1.234,56 and 1,234.56 are the same amount written by two spreadsheets; whichever of . and , comes last is the decimal point. Guessing turns 1.234 into one thousand two hundred and thirty-four. Dates are the opposite call: only YYYY-MM-DD is accepted, and anything else is refused rather than guessed, because 03/04/2026 is two different days depending on who exported it.

Bad rows are reported, not dropped. They are listed first in the preview and marked, and the summary counts them — the reader opened that step to find out what is wrong, and burying three broken rows under the first eight good ones answers a question nobody asked.

Nothing is written until Import, and a cell is written with textContent. A CSV is a file somebody was handed, and <img onerror> in a product name is the shortest path from a spreadsheet to stored XSS.

data-av-wizard-deeplink="false" is load-bearing on any wizard inside a <dialog>. You cannot deep-link into step 2 of a dialog nobody has opened, so the #step-N hash buys nothing — and it costs: the datagrid keeps its filter state in the hash on the same page, so an import stepping forward would silently throw away the filter the reader is looking at.

After a commit the module calls AdminVora.destroy() and AdminVora.init() on the grid. The grid captures its row list once, so an appended row is invisible to search, sort and pagination until it is rebound — visible in the table and absent from everything that acts on it.


Column chooser ​

html
<fieldset class="av-panel" data-av-columns="#orders-table">
  <legend class="av-panel__title">Columns</legend>
  <label class="av-columns__item">
    <input type="checkbox" class="av-form-check" data-av-col="status" checked> Status
  </label>
  <label class="av-columns__item">
    <input type="checkbox" class="av-form-check" data-av-col="total" checked> Total
  </label>
</fieldset>

Column visibility persists per table id in the store, so a user's layout survives navigation.


Virtual scrolling ​

For 10,000+ rows without pagination. The container is its own scroll port, and only the rows inside it are ever in the document — two spacer <tr>s stand in for everything above and below, so the scrollbar is the length of the whole set.

html
<div class="av-virtual"
     data-av-virtual="transactions"
     data-av-virtual-options='{"rowHeight": 48, "overscan": 8, "pageSize": 25}'
     style="--av-table-height: 640px"
     tabindex="0" role="region" aria-label="Transactions">
  <table class="av-table">
    <caption class="av-visually-hidden">Transactions</caption>
    <thead>
      <tr><th scope="col">Reference</th><th scope="col">Account</th></tr>
    </thead>
    <tbody></tbody>
  </table>
</div>

The rows come from the page, declared under the key in data-av-virtual:

js
window.AdminVoraConfig = window.AdminVoraConfig || {};
window.AdminVoraConfig.virtual = {
  transactions: {
    count: 10000,
    row(index) {
      return {
        cells: [
          { text: `TX-${100000 + index}`, header: true },
          { text: accounts[index % accounts.length] }
        ]
      };
    }
  }
};

A cell is { text, header, className } and nothing else — the row callback returns data, not markup, and the module writes it with textContent. Declare the config before the page's closing scripts; it is merged, not assigned, so it survives whatever else the shell sets.

With no entry under that key the rows already in the <tbody> are the source instead. That is the progressive-enhancement case: the markup is the truth and windowing only spares the browser the layout.

OptionDefaultDescription
rowHeight48Row height in px. Written back as --av-virtual-row, so the arithmetic and the painted box cannot disagree.
overscan8Rows rendered beyond each edge of the viewport.
pageSize25Rows per page in the paged view.
EventDetail
av:virtual:ready{ el, count, rowHeight }
av:virtual:range{ el, start, end, count }
av:virtual:mode{ el, mode } — virtual or paged

Important — a virtual table is not accessible by default. Screen readers cannot perceive rows that are not in the DOM. AdminVora sets aria-rowcount on the table and aria-rowindex on each rendered row, which is the ARIA-specified solution and still only half of one. The other half is a non-virtual alternative, so the component builds its own "Switch to paged view" control rather than leaving it to the page: the page that forgets to write it is the page that needed it. The paged view drops the spacers, renders a whole page of rows into the document, and switches back.

Not implemented: the specified server: { url, mode: 'range' } source. This build ships no server and its own gate fails any page that makes an off-origin request, so a fetching source could not be demonstrated or tested here. count plus row(index) is the seam it would sit behind — an implementation that resolves rows over the network fills in the same two members.


Pagination, and where the focus goes ​

The bar is rebuilt on every render — a windowed list of page numbers cannot survive being edited in place — and that is a dead end for a keyboard unless somebody puts the focus back:

js
const active = document.activeElement;
const held = pagesEl.contains(active) ? active.getAttribute('aria-label') || 'page' : null;

pagesEl.replaceChildren();
// … rebuild ‹ 1 2 … 9 › …
if (held) {
  const current = pagesEl.querySelector('[aria-current="page"]');
  const same = held === 'page' ? null : pagesEl.querySelector(`[aria-label="${held}"]`);
  (same && !same.disabled ? same : current).focus();
}

Press 2 with Enter and the button you pressed no longer exists, so focus falls to <body> and the next Tab starts again from "Skip to main content". It is the disabled-property defect buttons records, reached by a different route: the control is not neutered, it is gone. Nothing static can see it — axe reads markup, and a screenshot of page two looks perfect.

A page number hands focus to whichever button now carries aria-current="page": the reader pressed 2, they are on page 2, and that is the control under their finger. Previous and Next keep their own identity where they can — but they carry the disabled property, and stepping to the last page disables the very button that took you there, so the fallback is the current page rather than nowhere. npm run test:buttons presses both and asks where focus ended up.


Weighted rollups over a grid ​

data-av-pipeline turns a table of values into a set of totals that cannot disagree with it: one pass writes every per-row figure and every summary beside them.

html
<section data-av-pipeline data-av-currency="EUR">
  <p data-av-pipeline-open>—</p>
  <p data-av-pipeline-weighted>—</p>
  <p data-av-pipeline-committed>—</p>
  <p data-av-pipeline-average>—</p>
  <p data-av-pipeline-note>—</p>

  <dl class="av-detail-list">
    <div><dt>Discovery</dt>
      <dd data-av-pipeline-stage="discovery" data-av-pipeline-probability="30">30% — a real need</dd></div>
    <div><dt>Proposal</dt>
      <dd data-av-pipeline-stage="proposal" data-av-pipeline-probability="60">60% — pricing is with them</dd></div>
    <div><dt>Commit</dt>
      <dd data-av-pipeline-stage="commit" data-av-pipeline-probability="90">90% — waiting on signature</dd></div>
  </dl>

  <table class="av-table">
    <tr data-av-status="proposal" data-av-deal-value="24000000" data-av-deal="Group-wide rollout">
      …
      <td class="av-table__num" data-av-pipeline-row-weighted></td>
    </tr>
  </table>
</section>
AttributeOnMeans
data-av-pipelinethe sectionThe root. Rows are tr[data-av-status] inside it
data-av-pipeline-stagea legend entryThe stage this probability belongs to
data-av-pipeline-probabilitya legend entryWhole per cent. Read from the attribute, never from the text
data-av-deal-valuea rowValue in minor units
data-av-pipeline-row-weighteda cellWhere that row's weighted value goes
data-av-pipeline-open, -weighted, -committed, -average, -notethe sectionThe summary

Four things about it are decisions rather than arithmetic, and each is a way the obvious implementation goes wrong:

  • Probability belongs to the stage, not the deal. It is read off the legend the page already prints, so the configuration and the documentation are the same three lines. Put it on each row and two deals in one column will disagree, and the forecast becomes a number nobody can reproduce.

  • A stage with no legend entry is not in the forecast. That is how won and lost stay out without being special-cased: a won deal is revenue, and counting it here counts it once in the number the quarter is planned from and again in the number it is measured by.

  • A lost deal is not a nought-per-cent deal. It leaves the set entirely — which changes nothing in any sum and everything in the average, where dividing by every row reports a smaller typical deal than the team is actually working.

  • Committed is the last stage in the legend, derived from the order the page declares rather than from a stage name the runtime would have to know. A team that calls it "Contracting" gets the same behaviour without editing the module.

npm run test:crm recomputes all of it from the values and the legend, and checks the average against the wrong divisor as well as the right one.


States ​

The built-in grid tells two empty states apart, because they need different words and different actions:

  • [data-av-grid-empty] shows when a search or filter hides every row. Put a [data-av-grid-clear] button in it: the grid clears the search box and the status filter, puts focus back in the search box and emits av:grid:clear.
  • [data-av-grid-none] shows when the grid has no rows at all. This is first use, so it offers a way to create one, never a filter to clear.

Loading and error states are markup you render from the server:

html
<!-- Loading -->
<tbody aria-busy="true">
  <tr><td colspan="6"><div class="av-skeleton" style="block-size:20px"></div></td></tr>
  <tr><td colspan="6"><div class="av-skeleton" style="block-size:20px"></div></td></tr>
</tbody>

<!-- Empty -->
<tbody>
  <tr><td colspan="6">
    <div class="av-empty">
      <h3 class="av-empty__title">No orders yet</h3>
      <p class="av-empty__text">Orders appear here once customers start buying.</p>
      <a class="av-btn av-btn--sm av-btn--primary" href="/products/new">Add a product</a>
    </div>
  </td></tr>
</tbody>

<!-- Filtered empty — DIFFERENT message -->
<tbody>
  <tr><td colspan="6">
    <div class="av-empty">
      <h3 class="av-empty__title">No orders match “ellis”</h3>
      <button class="av-btn av-btn--sm av-btn--outline" type="button">Clear filters</button>
    </div>
  </td></tr>
</tbody>

<!-- Error -->
<tbody>
  <tr><td colspan="6">
    <div class="av-empty" role="alert">
      <h3 class="av-empty__title">Could not load orders</h3>
      <p class="av-empty__text">Request ID: 7f3a-91cd</p>
      <button class="av-btn av-btn--sm av-btn--primary" type="button">Try again</button>
    </div>
  </td></tr>
</tbody>

Events ​

EventDetail
av:datagrid:ready{ el, rows } — the grid element and its row count
av:tabulator:ready{ el, instance } — when the Tabulator path is used

There is no grid object to call methods on: configure the grid through its attributes, change the markup, and call AdminVora.init(el) to re-scan.


Accessibility checklist ​

  • [ ] <caption> describing the table (may be visually hidden)
  • [ ] scope="col" / scope="row" on all header cells
  • [ ] No empty <th> — use av-visually-hidden text
  • [ ] aria-sort updated on the sorted column
  • [ ] Sort controls are <button>, not clickable <th>
  • [ ] Every checkbox has a specific aria-label ("Select order 1042")
  • [ ] Selection count announced on change
  • [ ] Expand buttons have aria-expanded + aria-controls
  • [ ] Scrollable wrappers have tabindex="0" + role="region" + aria-label
  • [ ] Status conveyed with icon + text, not colour alone
  • [ ] Loading rows marked aria-busy="true"
  • [ ] Virtual tables set aria-rowcount / aria-rowindex and offer a paged alternative
  • [ ] Row actions reachable by keyboard without hover

Read next: Cards & Surfaces.

Documentation for @creativeigniter/adminvora