Skip to the page content

Editable tables

Seven ways to change data where it sits, from one cell to a whole batch of orders.

7 tables

Supplier catalog

Click a cell, or tab to it and press Enter, to open the right editor for that column. Enter keeps the change, Escape drops it, and edited lines wait for you to save them.

Inline cells
Supplier catalog. Column headers with buttons sort the table. Cells with an edit button can be changed.
Change status

No unsaved changes

Undo also works with Ctrl+Z while you're in the table.

Show code
<td><button class="edit-cell" data-field="cost">$412</button></td>

// Each column names its editor; validation runs before the value is kept.
{ field: 'sku',  editor: 'text',   pattern: /^[A-Z]{3}-\d{4}$/ },
{ field: 'cost', editor: 'money', min: 1 },   // a $ field, not a spinner
{ field: 'category', editor: 'select', options: categories }

Account owners

Edit turns the whole row into a small form, so a name and email change together or not at all.

Row editing
Account owner Plan and status Actions

5 accounts, 3 active

Show code
row.classList.add('is-editing');
row.replaceChildren(...fields.map(toInput), saveCancel);
// Save checks every field first; Cancel puts the old row back.

Supplies kit, car 12

Counts and switches that save the moment you touch them. The stock label follows the count as the carer uses supplies.

Toggles and steppers
Item In car Auto reorder

Show code
<div class="basalt-stepper basalt-stepper-sm" data-basalt-stepper>
  <button type="button" class="basalt-stepper-btn" data-basalt-step="-1" aria-label="One fewer"><i class="bi bi-dash-lg" aria-hidden="true"></i></button>
  <input type="number" class="basalt-stepper-input" min="0" max="999" value="6" inputmode="numeric" aria-label="Number of Nitrile gloves, box of 100 in the car">
  <button type="button" class="basalt-stepper-btn" data-basalt-step="1" aria-label="One more"><i class="bi bi-plus-lg" aria-hidden="true"></i></button>
</div>
<div class="form-check form-switch">
  <input class="form-check-input" type="checkbox" role="switch">
</div>
// The stepper fires change on its input for + and − and for typing.
countInput.addEventListener('change', (e) => setCount(row, e.target.value));

Marlo orders to pack

Check a few orders, or a whole page, and move them to the next status in one go. Your selection stays put while you search, sort or change page.

Select and bulk edit
Items

Show code
const selected = new Set();          // order ids, kept across pages
pageBox.indeterminate = some && !all;  // part of the page checked
apply.onclick = () => selected.forEach((id) => (byId[id].status = next));

Invoice #3117, Highpoint Outfitters

Every field is open, like a spreadsheet. Line totals, tax and the grand total add up as you type.

Live totals
Item Qty Unit price Amount Remove
Subtotal
Tax (8%)
Total due

Show code
<div class="basalt-stepper basalt-stepper-sm" data-basalt-stepper>
  <button type="button" class="basalt-stepper-btn" data-basalt-step="-1" aria-label="One fewer"><i class="bi bi-dash-lg" aria-hidden="true"></i></button>
  <input type="number" class="basalt-stepper-input" min="0" max="999" value="8" inputmode="numeric" aria-label="Quantity of Team Lead Course">
  <button type="button" class="basalt-stepper-btn" data-basalt-step="1" aria-label="One more"><i class="bi bi-plus-lg" aria-hidden="true"></i></button>
</div>
<div class="input-group input-group-sm">
  <span class="input-group-text" aria-hidden="true">$</span>
  <input type="text" inputmode="decimal" class="form-control text-end" value="649.00" aria-label="Unit price of Team Lead Course">
</div>

// Typing fires input, the stepper fires change; both add the lines up again.
['input', 'change'].forEach((type) => table.addEventListener(type, () => {
  const sub = lines.reduce((s, l) => s + l.qty * l.price, 0);
  totals.textContent = money(sub * 1.08);
}));

Keyboard

Every table on this page works without a mouse.

Shortcuts
Tab
Move to the next cell or control
Enter
Open a cell, or keep the change
Esc
Drop the change
Space
Check a row or flip a switch
Ctrl Z
Undo in the supplier catalog

Shop front page order

Drag a row by its handle, or use the arrow buttons, to set the order products appear on the Marlo shop's front page.

Reorder
# Product Category Move

Drag or use the arrows to move a product

Show code
row.draggable = true;
row.addEventListener('drop', () => tbody.insertBefore(dragged, row));
up.onclick = () => row.previousElementSibling?.before(row);

January price review

Type new prices and each row shows the change against today's price. Nothing goes live until you apply them, and any row can go back on its own.

Review before saving
Product New price Change Revert

Show code
const change = (next - today) / today;
badge.textContent = (change > 0 ? '+' : '') + pct(change);
apply.disabled = !rows.some((r) => r.next !== r.today);