Skip to the page content

Advanced tables

Seven working tables from the Marlo shop and its billing, each built on Bootstrap's table classes with a little plain JavaScript.

7 tables

Customer directory

A filter under every heading, so you can narrow Marlo customers by name, tier, city and spend at once. The header stays in place as you scroll the page.

Column filters

30 customers

Customer directory with a filter for each column
Show code
.tadv-table-sticky thead { position: sticky; top: 0; }

// every filter must match for a row to stay
const keep = (c) => Object.entries(filters).every(([key, value]) => test[key](c, value));

Order history

Search, filter by status, sort any column and page through 64 Marlo orders. Check rows to mark them shipped or download them as a CSV file.

Data grid

64 orders

Order history. Column headers with buttons sort the table.
Items

1–10 of 64 orders

Show code
<th scope="col" aria-sort="descending">
  <button type="button" class="tadv-sort" data-sort="date">Date</button>
</th>

// search, filter, sort, then slice one page
rows = orders.filter(matches).sort(by(key, dir));
page = rows.slice((n - 1) * size, n * size);

Marlo price list

Click a price, stock count or category to change it. Enter keeps the change, Esc puts it back. Nothing is saved until you press Save.

Inline edit
Marlo price list. Category, price and stock cells can be edited.
Product Category Price In stock

No unsaved changes

Show code
<td><button type="button" class="tadv-cell" data-edit="price">$585.00</button></td>

input.addEventListener('keydown', (e) => {
  if (e.key === 'Enter') commit();
  if (e.key === 'Escape') cancel();
});

Front page order

The order products appear on the shop's front page. Drag a row by its handle, or use the arrow buttons from the keyboard.

Reorder rows
Front page product order. Rows can be moved up and down.
# Product Sold this month Move

Sorted by units sold

Show code
<tr draggable="true"> … </tr>

row.addEventListener('drop', () => move(dragged, row));
upButton.addEventListener('click', () => move(row, row.previousElementSibling));

Account subscriptions

Open a row to see the billing address, add-ons and the last three invoices, without leaving the list.

Expandable rows

6 subscriptions

Account subscriptions. Each row opens to show its details.
Details Account Plan Next renewal Status
Show code
<button type="button" aria-expanded="false" aria-controls="sub-1-detail">…</button>
<tr id="sub-1-detail" hidden><td colspan="5">…</td></tr>

Account invoices

Grouped by month or by customer, with a subtotal on each group and the grand total underneath. Click a group to fold it away.

Grouped rows
Account invoices in groups, each with a subtotal
Invoice Customer Due Status Amount
Show code
<tr class="tadv-group">
  <th scope="rowgroup" colspan="4"><button aria-expanded="true">September</button></th>
  <td class="text-end">$9,614.20</td>
</tr>

Clothing and accessory catalog

Choose which columns to show, switch to compact rows or stripes, and scroll sideways with the product name held in place.

Column controls

9 of 9 columns

Clothing and accessory catalog. The product column stays in place when scrolling sideways.
Product
Show code
<table class="table table-striped table-sm">   // Compact and Striped

.tadv-table-pin th:first-child,
.tadv-table-pin td:first-child { position: sticky; left: 0; }