Skip to the page content

Data tables

Nine working tables from the shop and the back office, each built on Bootstrap's own table classes.

9 tables

Recent Marlo orders

Everything at once: search, a status filter, sortable columns, row selection with bulk actions, and paging. Selections stay checked while you move between pages.

Full table
Recent orders. Column headers with buttons sort the table.

Loading orders

Show code
const orders = tableKit(card, {
  records: ORDERS,
  startSort: { key: 'date', dir: 'desc' },
  perPage: 10,
  hits: (sale, query) => haystack(sale).includes(query),
  passes: (sale) => !onlyStatus || sale.status === onlyStatus,
  toRow: (sale) => `<tr>...</tr>`,
});
orders.redraw();

Team members

Click a header to sort, click again to flip it. Text sorts A to Z, numbers low to high and dates oldest first.

Sorting
Team members. Column headers with buttons sort the table.

Sorted by team member, A to Z

Show code
<th scope="col" aria-sort="ascending" data-dt-sort="name">
  <button type="button" class="dt-sort">Team member</button>
</th>
// tableKit() moves aria-sort to the clicked header
tableKit(card, { records: STAFF, startSort: { key: 'name', dir: 'asc' } });

Customers

Type to narrow the list. Matches are marked in each column, and an empty result says so with a way back.

Search

12 customers

Customers, filtered by the search box above.
Customer City Spent
Show code
input.addEventListener('input', () => {
  table.setSearch(input.value);   // back to page 1
});
// cells pass through markHits(text, query), which wraps hits in <mark>

Marlo clothing

Filters that work together: a category, a brand, a price ceiling and a stock switch. The count and the reset button follow what is applied.

Filters

$700

9 products

Marlo clothing, narrowed by the filters above. Column headers with buttons sort the table.
Show code
tableKit(card, {
  records: GARMENTS,
  passes: (item) =>
    (!chosen.category || item.cat === chosen.category) &&
    (!chosen.maker || item.brand === chosen.maker) &&
    item.price <= chosen.maxPrice &&
    (!chosen.inStockOnly || item.stock > 0),
});

Customer invoices

Each row opens to show its line items, so the list stays short until you need the detail.

Expandable rows
Customer invoices. Each row has a button that shows its line items.
Details Invoice Due Status Amount
Show code
<button class="dt-expander" aria-expanded="false"
        aria-controls="whs-4315-items">...</button>
...
<tr class="dt-detail" id="whs-4315-items" hidden>
  <td colspan="5"> line items </td>
</tr>

Marlo stock movements

A long log that grows with the page. The header row stays pinned under the top bar while you scroll.

Sticky header
Marlo stock movements for the last five weeks, newest first
Date Item Movement Qty On hand

30 movements

Show code
/* No inner scroll: the header sticks to the page,
   just under the 68px top bar. */
.dt-scroll-sticky { overflow: clip; }
.dt-table-sticky thead th {
  position: sticky;
  top: 68px;
  background: var(--basalt-plane);
}

Maintenance plans

Edit turns a whole row into fields. Enter saves and Escape cancels. Pause and resume work in one click.

Row editing
Maintenance plans. Each row can be edited, paused or resumed.
Customer Plan Units Property Every Next visit Status Actions

6 active, 2 paused

Show code
row.addEventListener('keydown', (e) => {
  if (e.key === 'Enter') keepEdits(row);
  if (e.key === 'Escape') discard(row);  // focus returns to Edit
});

Service price list

Choose the columns, tighten the rows, or add stripes for long reads. Supplies are hidden.

Columns and density
Service price list. Columns can be shown or hidden from the Columns menu.
Service Industry Supplies Time on site Skill level Flat rate
Show code
table.classList.toggle('table-sm', compact);
table.classList.toggle('table-striped', striped);
// hide a column: every cell carries data-dt-col
table.querySelectorAll('[data-dt-col="parts"]')
  .forEach((cell) => { cell.hidden = true; });

Marlo sales by category

The last three full months with a row total, a share of the quarter and a footer that adds it all up.

Totals
Marlo sales by category for the last three months
Category Month 1 Month 2 Month 3 Total Share
Show code
<tfoot>
  <tr>
    <th scope="row">Total</th>
    <td class="text-end">$53,870</td> ...
  </tr>
</tfoot>