Data
The table sorts and filters rows in the browser, and with source it hands that work to your server.
column.value(row) returns the cell value. Numbers and dates sort by size, strings alphabetically in the current language, and empty null values go last. sortable: false turns sorting off for a column.
format(value, row) turns the value into the cell text. Group labels, totals and the filter list have no row, so undefined comes in its place.
On large data sorting, filters and grouping run in parts and show progress. When the work is done, the settle event arrives with the row count.
The select-all checkbox selects the rows visible after filtering. The loading prop shows placeholders instead of rows, and empty rows show Empty or the empty slot.
Filters and totals
The filter in the column menu depends on the column type: text, number, date, or a list of values for boolean. The filter field picks another filter (text, number, date or set), and false removes it. With filter: 'set' the filter offers a list of values to pick from.
The v-model:quick model searches all text columns at once.
A long list shows the first hundred values, and the search above the list finds the rest. "Select all" with a box unchecked afterwards gives a filter with exclude: true: it hides the named values, and values that appear later stay visible.
The list is marked busy while its values are gathered. If gathering takes a while, "Loading the values…" stands in its place.
A column with aggregate adds a totals row at the bottom, such as a sum or an average. The totals row shows the totalsLabel caption and the number of rows left after filtering.
A number column computes sum, count, avg, min and max, a date column min, max and count, and text and boolean columns count. A custom function works for a column of any type.
Orders of the month
# | Customer | City | Status | Total | |
|---|---|---|---|---|---|
20401 | Peter Wolfe | Boston | Delivered | $307 | |
20402 | Lena Ortiz | Chicago | Delivered | $138 | |
20403 | Tim Sayed | Denver | Delivered | $507 | |
20404 | Vera Lane | Boston | Canceled | $180 | |
20405 | Glen Nash | Austin | Delivered | $175 | |
20406 | Evan Porter | Seattle | Shipped | $199 | |
20407 | Mary Cooper | Portland | Shipped | $416 | |
20408 | Paul Hawkins | Boston | Shipped | $368 | |
20409 | Olga Graham | Chicago | Paid | $139 | |
20410 | Sam Ellis | Denver | Paid | $863 | |
20411 | Nina Hart | Austin | Awaiting payment | $498 | |
20412 | Alina Yusuf | Portland | Awaiting payment | $187 | |
Total12 rows | $3,977 |
<template> <div class="flex flex-col gap-3"> <NuiInput v-model="quick" type="search" placeholder="Search orders" aria-label="Search orders" class="max-w-xs" /> <NuiTable v-model:filters="filters" v-model:quick="quick" :columns="columns" :rows="orders" :get-key="keyOf" totals-label="Total" caption="Orders of the month" /> </div></template><script setup lang="ts">import { ref } from 'vue';import { NuiInput } from '@numior/kit';import { NuiTable, type NuiTableColumn, type NuiTableFilters } from '@numior/kit/table';import { ORDER_STATUSES, orders, type Order } from './orders';const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0,});const columns: NuiTableColumn<Order>[] = [ { key: 'id', label: '#', type: 'number', width: 96, filter: false, value: (row) => row.id, format: (value) => String(value), }, { key: 'customer', label: 'Customer', type: 'text', width: 150, flex: 1, value: (row) => row.customer, }, { key: 'city', label: 'City', type: 'text', width: 120, filter: 'set', value: (row) => row.city, }, { key: 'status', label: 'Status', type: 'text', width: 140, filter: 'set', value: (row) => ORDER_STATUSES[row.status], }, { key: 'total', label: 'Total', type: 'number', width: 130, aggregate: 'sum', value: (row) => row.total, format: (value) => money.format(value), },];const keyOf = (order: Order): number => order.id;const quick = ref('');const filters = ref<NuiTableFilters>([]);</script>export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];Groups
The v-model:groupBy model groups rows by column values, and totals are computed for each group. Columns can share a common header when you describe a column group as { key, label, children }.
A group label sits in the column the rows are grouped by, and each nested level sits in its own column. Place that column near the start so the label stays in view on a phone.
- No grouping
- By status
Orders by group
Order | Buyer | |||
|---|---|---|---|---|
# | Status | Customer | Total | |
Awaiting payment(2) | $685 | |||
Canceled(1) | $180 | |||
Delivered(4) | $1,127 | |||
Paid(2) | $1,002 | |||
Shipped(3) | $983 | |||
Total12 rows | $3,977 | |||
<template> <div class="flex flex-col gap-3"> <NuiSelect v-model="grouping" :options="groupings" label="Grouping" class="max-w-xs" /> <NuiTable v-model:group-by="groupBy" v-model:expanded="expanded" :columns="columns" :rows="orders" :get-key="keyOf" caption="Orders by group" /> </div></template><script setup lang="ts">import { computed, ref } from 'vue';import { NuiSelect, type NuiOptionSource } from '@numior/kit';import { NuiTable, type NuiTableColumnDef, type TableNodeId } from '@numior/kit/table';import { ORDER_STATUSES, orders, type Order } from './orders';const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0,});const columns: NuiTableColumnDef<Order>[] = [ { key: 'order', label: 'Order', children: [ { key: 'id', label: '#', type: 'number', width: 100, reorderable: false, value: (row) => row.id, format: (value) => String(value), }, { key: 'status', label: 'Status', type: 'text', width: 200, value: (row) => ORDER_STATUSES[row.status], }, ], }, { key: 'buyer', label: 'Buyer', children: [ { key: 'customer', label: 'Customer', type: 'text', width: 150, flex: 1, value: (row) => row.customer, }, ], }, { key: 'total', label: 'Total', type: 'number', width: 130, aggregate: 'sum', value: (row) => row.total, format: (value) => money.format(value), },];const groupings: NuiOptionSource<string> = [ { value: 'none', label: 'No grouping' }, { value: 'status', label: 'By status' },];const keyOf = (order: Order): number => order.id;const groupBy = ref<string[]>(['status']);const expanded = ref<TableNodeId[]>([]);const grouping = computed({ get: (): string => groupBy.value[0] ?? 'none', set: (value: string | null) => { groupBy.value = value === null || value === 'none' ? [] : [value]; expanded.value = []; },});</script>export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];Pages
The pagination prop shows a Pagination under the table. With remote and total the application handles sorting, filters and page changes, and the table shows the rows and emits events.
All orders
# | Customer | Total | |
|---|---|---|---|
21000 | Paul Hawkins | $297 | |
21001 | Alina Yusuf | $148 | |
21002 | Vera Lane | $498 | |
21003 | Mary Cooper | $1,653 | |
21004 | Lena Ortiz | $1,041 | |
21005 | Olga Graham | $413 | |
21006 | Alina Yusuf | $1,125 | |
21007 | Mary Cooper | $336 | |
21008 | Paul Hawkins | $128 | |
21009 | Mary Cooper | $329 |
<template> <NuiTable v-model:page-size="pageSize" :columns="columns" :rows="orders" :get-key="keyOf" :pagination="{ pageSizes: [5, 10, 20] }" caption="All orders" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiTable, type NuiTableColumn } from '@numior/kit/table';import { ordersOf } from './many-orders';import type { Order } from './orders';const orders = ordersOf(42);const money = new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', maximumFractionDigits: 0,});const columns: NuiTableColumn<Order>[] = [ { key: 'id', label: '#', type: 'number', width: 96, value: (row) => row.id, format: (value) => String(value), }, { key: 'customer', label: 'Customer', type: 'text', width: 200, flex: 1, value: (row) => row.customer, }, { key: 'total', label: 'Total', type: 'number', width: 140, value: (row) => row.total, format: (value) => money.format(value), },];const keyOf = (order: Order): number => order.id;const pageSize = ref(10);</script>import { orders, type Order, type OrderLine, type OrderStatus } from './orders';import { pick, seeded, type Random } from './random';const FIRST_ID = 21_000;const LAST_DAY = Date.UTC(2026, 8, 27);const DAY = 86_400_000;const DAYS = 180;const MAX_LINES = 3;const MAX_QUANTITY = 3;const STATUSES: readonly OrderStatus[] = [ 'delivered', 'delivered', 'delivered', 'delivered', 'shipped', 'shipped', 'paid', 'paid', 'pending', 'cancelled',];const LINES = orders.flatMap((order) => order.lines);const upTo = (random: Random, limit: number): number => 1 + Math.floor(random() * limit);const lineOf = (random: Random): OrderLine => ({ ...pick(random, LINES), quantity: upTo(random, MAX_QUANTITY),});const orderOf = (random: Random, index: number): Order => { const buyer = pick(random, orders); const lines = Array.from({ length: upTo(random, MAX_LINES) }, () => lineOf(random)); return { id: FIRST_ID + index, date: new Date(LAST_DAY - Math.floor(random() * DAYS) * DAY).toISOString().slice(0, 10), customer: buyer.customer, city: buyer.city, status: pick(random, STATUSES), payment: pick(random, orders).payment, delivery: pick(random, orders).delivery, manager: pick(random, orders).manager, total: lines.reduce((sum, line) => sum + line.quantity * line.price, 0), lines, };};export const ordersOf = (count: number, seed = 1): Order[] => { const random = seeded(seed); return Array.from({ length: count }, (_, index) => orderOf(random, index));};export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];export type Random = () => number;export const seeded = (seed: number): Random => { let state = seed >>> 0; return () => { state = (state + 0x6d2b79f5) >>> 0; const mixed = Math.imul(state ^ (state >>> 15), state | 1); const spread = mixed ^ (mixed + Math.imul(mixed ^ (mixed >>> 7), mixed | 61)); return ((spread ^ (spread >>> 14)) >>> 0) / 4_294_967_296; };};export const pick = <Item>(random: Random, items: readonly Item[]): Item => { const item = items[Math.floor(random() * items.length)]; if (item === undefined) { throw new RangeError('pick needs a list with items'); } return item;};Row tree
The getChildren function turns the table into a tree: a row with children gets an arrow, and the children are indented. The keys of expanded rows are kept in v-model:expanded.
When the children are not loaded yet, mark the row with hasChildren. On expand the table emits the load event and shows the children once they arrive. A click on the arrow expands the row without moving the focus or selecting a cell.
The totals row of a tree counts every row left after the filters, collapsed ones included. The parents of found rows stay in the tree and count too.
Catalog by section
Section | Products | In stock | |
|---|---|---|---|
Furniture | 7 | 81 | |
Chairs | 3 | 46 | |
Tables | 2 | 22 | |
Storage | 2 | 13 | |
Lighting | 3 | 81 | |
Textiles | 2 | 136 |
<template> <NuiTable v-model:expanded="expanded" :columns="columns" :rows="sections" :get-key="keyOf" :get-children="childrenOf" :has-children="isLazy" caption="Catalog by section" @load="load" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiTable, type NuiTableColumn, type TableNodeId } from '@numior/kit/table';import { categories, products, type Category } from './products';interface Section { readonly id: string; readonly name: string; readonly count: number; readonly stock: number; readonly children?: readonly Section[]; readonly lazy?: boolean;}const LAZY = 'textile';const LOAD_DELAY = 700;const sectionOf = (category: Category): Section => { const leaves = new Set((category.children ?? [category]).map((leaf) => leaf.value)); return products.reduce<Section>( (section, product) => leaves.has(product.category) ? { ...section, count: section.count + 1, stock: section.stock + product.stock } : section, { id: category.value, name: category.label, count: 0, stock: 0 }, );};const subsectionsOf = (category: Category): readonly Section[] => (category.children ?? []).map(sectionOf);const SECTIONS: readonly Section[] = categories.map((category) => category.value === LAZY ? { ...sectionOf(category), lazy: true } : { ...sectionOf(category), children: subsectionsOf(category) },);const LOADED = new Map(categories.map((category) => [category.value, subsectionsOf(category)]));const columns: NuiTableColumn<Section>[] = [ { key: 'name', label: 'Section', type: 'text', width: 220, flex: 1, value: (row) => row.name }, { key: 'count', label: 'Products', type: 'number', width: 120, value: (row) => row.count }, { key: 'stock', label: 'In stock', type: 'number', width: 120, value: (row) => row.stock },];const keyOf = (section: Section): string => section.id;const childrenOf = (section: Section): readonly Section[] | undefined => section.children;const isLazy = (section: Section): boolean => section.lazy === true;const sections = ref<readonly Section[]>(SECTIONS);const expanded = ref<TableNodeId[]>(['furniture']);const load = (section: Section): void => { setTimeout(() => { sections.value = sections.value.map((entry) => entry.id === section.id ? { ...entry, children: LOADED.get(entry.id) ?? [] } : entry, ); }, LOAD_DELAY);};</script>export interface Product { readonly sku: string; readonly name: string; readonly category: string; readonly price: number; readonly stock: number;}export interface Category { readonly value: string; readonly label: string; readonly children?: readonly Category[];}export const categories: readonly Category[] = [ { value: 'furniture', label: 'Furniture', children: [ { value: 'seating', label: 'Chairs' }, { value: 'tables', label: 'Tables' }, { value: 'storage', label: 'Storage' }, ], }, { value: 'lighting', label: 'Lighting', children: [ { value: 'lamps', label: 'Lamps' }, { value: 'pendants', label: 'Pendants' }, ], }, { value: 'textile', label: 'Textiles', children: [ { value: 'throws', label: 'Throws' }, { value: 'pillows', label: 'Pillows' }, ], },];export const products: readonly Product[] = [ { sku: 'S-101', name: 'Oslo armchair', category: 'seating', price: 249, stock: 12 }, { sku: 'S-104', name: 'Bergen chair', category: 'seating', price: 89, stock: 34 }, { sku: 'S-110', name: 'Loft stool', category: 'seating', price: 45, stock: 0 }, { sku: 'T-201', name: 'Malmo desk', category: 'tables', price: 329, stock: 7 }, { sku: 'T-207', name: 'Tromso coffee table', category: 'tables', price: 139, stock: 15 }, { sku: 'H-301', name: 'Vik shelving unit', category: 'storage', price: 199, stock: 9 }, { sku: 'H-305', name: 'Fjord dresser', category: 'storage', price: 299, stock: 4 }, { sku: 'L-401', name: 'Nord table lamp', category: 'lamps', price: 69, stock: 41 }, { sku: 'L-408', name: 'Arc floor lamp', category: 'lamps', price: 119, stock: 18 }, { sku: 'L-412', name: 'Sphere pendant', category: 'pendants', price: 99, stock: 22 }, { sku: 'X-501', name: 'Wool throw', category: 'throws', price: 59, stock: 56 }, { sku: 'X-507', name: 'Linen pillow', category: 'pillows', price: 29, stock: 80 },];Row details
The detail slot adds an arrow to the row, and an expanded row shows the slot content beneath it across the full table width. The keys of expanded rows are kept in v-model:expanded, and hasDetail keeps the arrow only on rows that have details.
The arrow keys pass through a details block, and Tab moves the focus inside it. Clicks, keys and pastes inside the block go to its content, so a second table can live there.
Selection, copying and cell editing skip details blocks, and a page keeps the same number of rows. With height the table counts the block height in the scroll. Details do not work in a row tree.
Orders and their items
Order | Customer | City | Total | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
20401 | Peter Wolfe | Boston | 307 | |||||||||||||||||||||
Courier · Card
| ||||||||||||||||||||||||
20402 | Lena Ortiz | Chicago | 138 | |||||||||||||||||||||
20403 | Tim Sayed | Denver | 507 | |||||||||||||||||||||
20404 | Vera Lane | Boston | 180 | |||||||||||||||||||||
20405 | Glen Nash | Austin | 175 | |||||||||||||||||||||
<template> <NuiTable v-model:expanded="expanded" :columns="columns" :rows="latest" :get-key="keyOf" :has-detail="isActive" caption="Orders and their items" > <template #detail="{ row }"> <div class="flex flex-col gap-3"> <p class="text-sm text-muted-foreground">{{ deliveryOf(row) }}</p> <NuiTable :columns="lineColumns" :rows="row.lines" :get-key="skuOf" size="sm" label="Order items" totals-label="Total" /> </div> </template> </NuiTable></template><script setup lang="ts">import { ref } from 'vue';import { NuiTable, type NuiTableColumn, type TableNodeId } from '@numior/kit/table';import { DELIVERIES, PAYMENTS, orders, type Order, type OrderLine } from './orders';const latest = orders.slice(0, 5);const costOf = (line: OrderLine): number => line.quantity * line.price;const columns: NuiTableColumn<Order>[] = [ { key: 'id', label: 'Order', type: 'number', width: 120, value: (row) => row.id, format: (value) => String(value), }, { key: 'customer', label: 'Customer', type: 'text', width: 200, flex: 1, value: (row) => row.customer, }, { key: 'city', label: 'City', type: 'text', width: 160, value: (row) => row.city }, { key: 'total', label: 'Total', type: 'number', width: 130, value: (row) => row.total },];const lineColumns: NuiTableColumn<OrderLine>[] = [ { key: 'name', label: 'Item', type: 'text', width: 200, flex: 1, value: (line) => line.name }, { key: 'quantity', label: 'Qty', type: 'number', width: 100, value: (line) => line.quantity }, { key: 'price', label: 'Price', type: 'number', width: 110, value: (line) => line.price }, { key: 'cost', label: 'Cost', type: 'number', width: 120, aggregate: 'sum', value: costOf },];const keyOf = (order: Order): number => order.id;const skuOf = (line: OrderLine): string => line.sku;const isActive = (order: Order): boolean => order.status !== 'cancelled';const deliveryOf = (order: Order): string => `${DELIVERIES[order.delivery]} · ${PAYMENTS[order.payment]}`;const expanded = ref<TableNodeId[]>([20401]);</script>export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];Ten thousand rows
With height the table scrolls inside itself and renders only the visible rows of rowHeight height and the visible columns.
A column with pin: 'start' or pin: 'end' stays in place on horizontal scroll, and rows from pinnedRows stay under the header. A column can also be pinned or hidden from its menu, and hideable: false keeps it from being hidden. The column the rows are grouped by cannot be hidden until the grouping is removed.
10,000 readings
# | Sensor | Zone | Temperature | Humidity | Time | |
|---|---|---|---|---|---|---|
1 | Sensor 1 | Warehouse | 18 °C | 40 % | 9/1/26, 12:00 AM | |
1 | Sensor 1 | Warehouse | 18 °C | 40 % | 9/1/26, 12:00 AM | |
2 | Sensor 2 | Workshop | 25 °C | 53 % | 9/1/26, 12:01 AM | |
3 | Sensor 3 | Office | 32 °C | 66 % | 9/1/26, 12:02 AM | |
4 | Sensor 4 | Server room | 24 °C | 44 % | 9/1/26, 12:03 AM | |
5 | Sensor 5 | Warehouse | 31 °C | 57 % | 9/1/26, 12:04 AM | |
6 | Sensor 6 | Workshop | 23 °C | 70 % | 9/1/26, 12:05 AM | |
7 | Sensor 7 | Office | 30 °C | 48 % | 9/1/26, 12:06 AM | |
8 | Sensor 8 | Server room | 22 °C | 61 % | 9/1/26, 12:07 AM | |
9 | Sensor 9 | Warehouse | 29 °C | 74 % | 9/1/26, 12:08 AM | |
10 | Sensor 10 | Workshop | 21 °C | 52 % | 9/1/26, 12:09 AM | |
11 | Sensor 11 | Office | 28 °C | 65 % | 9/1/26, 12:10 AM | |
12 | Sensor 12 | Server room | 20 °C | 43 % | 9/1/26, 12:11 AM | |
13 | Sensor 13 | Warehouse | 27 °C | 56 % | 9/1/26, 12:12 AM | |
14 | Sensor 14 | Workshop | 19 °C | 69 % | 9/1/26, 12:13 AM | |
15 | Sensor 15 | Office | 26 °C | 47 % | 9/1/26, 12:14 AM | |
16 | Sensor 16 | Server room | 18 °C | 60 % | 9/1/26, 12:15 AM | |
17 | Sensor 17 | Warehouse | 25 °C | 73 % | 9/1/26, 12:16 AM | |
18 | Sensor 18 | Workshop | 32 °C | 51 % | 9/1/26, 12:17 AM | |
19 | Sensor 19 | Office | 24 °C | 64 % | 9/1/26, 12:18 AM | |
20 | Sensor 20 | Server room | 31 °C | 42 % | 9/1/26, 12:19 AM | |
21 | Sensor 21 | Warehouse | 23 °C | 55 % | 9/1/26, 12:20 AM | |
22 | Sensor 22 | Workshop | 30 °C | 68 % | 9/1/26, 12:21 AM | |
23 | Sensor 23 | Office | 22 °C | 46 % | 9/1/26, 12:22 AM | |
24 | Sensor 24 | Server room | 29 °C | 59 % | 9/1/26, 12:23 AM | |
25 | Sensor 1 | Warehouse | 21 °C | 72 % | 9/1/26, 12:24 AM | |
26 | Sensor 2 | Workshop | 28 °C | 50 % | 9/1/26, 12:25 AM | |
27 | Sensor 3 | Office | 20 °C | 63 % | 9/1/26, 12:26 AM | |
28 | Sensor 4 | Server room | 27 °C | 41 % | 9/1/26, 12:27 AM | |
29 | Sensor 5 | Warehouse | 19 °C | 54 % | 9/1/26, 12:28 AM | |
30 | Sensor 6 | Workshop | 26 °C | 67 % | 9/1/26, 12:29 AM |
<template> <NuiTable :columns="columns" :rows="readings" :get-key="keyOf" :pinned-rows="pinned" height="20rem" size="sm" caption="10,000 readings" /></template><script setup lang="ts">import { NuiTable, type NuiTableColumn } from '@numior/kit/table';interface Reading { readonly id: number; readonly sensor: string; readonly zone: string; readonly value: number; readonly humidity: number; readonly at: number;}const ZONES = ['Warehouse', 'Workshop', 'Office', 'Server room'];const START = Date.UTC(2026, 8, 1);const MINUTE = 60_000;const readings: Reading[] = Array.from({ length: 10_000 }, (_, index) => ({ id: index + 1, sensor: `Sensor ${(index % 24) + 1}`, zone: ZONES[index % ZONES.length] ?? '', value: 18 + ((index * 7) % 15), humidity: 40 + ((index * 13) % 35), at: START + index * MINUTE,}));const pinned = readings.slice(0, 1);const when = new Intl.DateTimeFormat('en-US', { dateStyle: 'short', timeStyle: 'short' });const columns: NuiTableColumn<Reading>[] = [ { key: 'id', label: '#', type: 'number', width: 88, pin: 'start', value: (row) => row.id, format: (value) => String(value), }, { key: 'sensor', label: 'Sensor', type: 'text', width: 160, value: (row) => row.sensor }, { key: 'zone', label: 'Zone', type: 'text', width: 140, filter: 'set', value: (row) => row.zone }, { key: 'value', label: 'Temperature', type: 'number', width: 150, value: (row) => row.value, format: (value) => `${value} °C`, }, { key: 'humidity', label: 'Humidity', type: 'number', width: 150, value: (row) => row.humidity, format: (value) => `${value} %`, }, { key: 'at', label: 'Time', type: 'date', width: 180, value: (row) => row.at, format: (value) => when.format(value), },];const keyOf = (reading: Reading): number => reading.id;</script>With rowHeight="auto" each row is as tall as its content, and the table still renders only the visible rows. Columns with wrap wrap their text.
The table measures rows as they appear on screen. While the scroll height settles, the row under the header does not move.
2,000 requests
No. | Author | Topic | Request | |
|---|---|---|---|---|
1 | Peter Wolfe | Delivery | Thanks, everything arrived. | |
2 | Lena Ortiz | Warranty | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
3 | Tim Sayed | Return | The courier came a day late. Please tell me when the second box arrives. | |
4 | Vera Lane | Payment | Thanks, everything arrived. | |
5 | Glen Nash | Delivery | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
6 | Evan Porter | Warranty | The courier came a day late. Please tell me when the second box arrives. | |
7 | Mary Cooper | Return | Thanks, everything arrived. | |
8 | Paul Hawkins | Payment | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
9 | Olga Graham | Delivery | The courier came a day late. Please tell me when the second box arrives. | |
10 | Sam Ellis | Warranty | Thanks, everything arrived. | |
11 | Nina Hart | Return | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
12 | Alina Yusuf | Payment | The courier came a day late. Please tell me when the second box arrives. | |
13 | Peter Wolfe | Delivery | Thanks, everything arrived. | |
14 | Lena Ortiz | Warranty | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
15 | Tim Sayed | Return | The courier came a day late. Please tell me when the second box arrives. | |
16 | Vera Lane | Payment | Thanks, everything arrived. | |
17 | Glen Nash | Delivery | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
18 | Evan Porter | Warranty | The courier came a day late. Please tell me when the second box arrives. | |
19 | Mary Cooper | Return | Thanks, everything arrived. | |
20 | Paul Hawkins | Payment | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
21 | Olga Graham | Delivery | The courier came a day late. Please tell me when the second box arrives. | |
22 | Sam Ellis | Warranty | Thanks, everything arrived. | |
23 | Nina Hart | Return | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
24 | Alina Yusuf | Payment | The courier came a day late. Please tell me when the second box arrives. | |
25 | Peter Wolfe | Delivery | Thanks, everything arrived. | |
26 | Lena Ortiz | Warranty | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
27 | Tim Sayed | Return | The courier came a day late. Please tell me when the second box arrives. | |
28 | Vera Lane | Payment | Thanks, everything arrived. | |
29 | Glen Nash | Delivery | The payment went through twice. Refund the extra charge and send the receipt to my email. | |
30 | Evan Porter | Warranty | The courier came a day late. Please tell me when the second box arrives. |
<template> <NuiTable :columns="columns" :rows="requests" :get-key="keyOf" height="20rem" row-height="auto" caption="2,000 requests" /></template><script setup lang="ts">import { NuiTable, type NuiTableColumn } from '@numior/kit/table';import { customers } from './customers';interface Request { readonly id: number; readonly author: string; readonly topic: string; readonly text: string;}const TOPICS = ['Delivery', 'Payment', 'Return', 'Warranty'];const TEXTS = [ 'Thanks, everything arrived.', 'The courier came a day late. Please tell me when the second box arrives.', 'The payment went through twice. Refund the extra charge and send the receipt to my email.',];const NAMES = customers.map((customer) => customer.name);const requests: Request[] = Array.from({ length: 2000 }, (_, index) => ({ id: index + 1, author: NAMES[index % NAMES.length] ?? '', topic: TOPICS[(index * 3) % TOPICS.length] ?? '', text: TEXTS[(index * 5) % TEXTS.length] ?? '',}));const columns: NuiTableColumn<Request>[] = [ { key: 'id', label: 'No.', type: 'number', width: 100, value: (row) => row.id, format: (value) => String(value), }, { key: 'author', label: 'Author', type: 'text', width: 170, value: (row) => row.author }, { key: 'topic', label: 'Topic', type: 'text', width: 120, filter: 'set', value: (row) => row.topic, }, { key: 'text', label: 'Request', type: 'text', width: 280, flex: 1, wrap: true, value: (row) => row.text, },];const keyOf = (request: Request): number => request.id;</script>export interface Customer { readonly id: number; readonly name: string; readonly city: string; readonly email: string; readonly phone: string; readonly orders: number; readonly spent: number;}export const customers: readonly Customer[] = [ { id: 1, name: 'Peter Wolfe', city: 'Boston', email: 'peter.wolfe@example.com', phone: '(617) 555-0101', orders: 14, spent: 2480, }, { id: 2, name: 'Lena Ortiz', city: 'Chicago', email: 'lena.ortiz@example.com', phone: '(312) 555-0102', orders: 3, spent: 295, }, { id: 3, name: 'Tim Sayed', city: 'Denver', email: 'tim.sayed@example.com', phone: '(303) 555-0103', orders: 8, spent: 1920, }, { id: 4, name: 'Vera Lane', city: 'Boston', email: 'vera.lane@example.com', phone: '(617) 555-0104', orders: 1, spent: 180, }, { id: 5, name: 'Glen Nash', city: 'Austin', email: 'glen.nash@example.com', phone: '(512) 555-0105', orders: 5, spent: 645, }, { id: 6, name: 'Evan Porter', city: 'Seattle', email: 'evan.porter@example.com', phone: '(206) 555-0106', orders: 2, spent: 440, }, { id: 7, name: 'Mary Cooper', city: 'Portland', email: 'mary.cooper@example.com', phone: '(503) 555-0107', orders: 11, spent: 1300, }, { id: 8, name: 'Paul Hawkins', city: 'Boston', email: 'paul.hawkins@example.com', phone: '(617) 555-0108', orders: 6, spent: 965, }, { id: 9, name: 'Olga Graham', city: 'Chicago', email: 'olga.graham@example.com', phone: '(312) 555-0109', orders: 4, spent: 530, }, { id: 10, name: 'Sam Ellis', city: 'Denver', email: 'sam.ellis@example.com', phone: '(303) 555-0110', orders: 9, spent: 2190, }, { id: 11, name: 'Nina Hart', city: 'Austin', email: 'nina.hart@example.com', phone: '(512) 555-0111', orders: 2, spent: 755, }, { id: 12, name: 'Alina Yusuf', city: 'Portland', email: 'alina.yusuf@example.com', phone: '(503) 555-0112', orders: 7, spent: 820, },];Server data
The source prop loads rows from a server. The fetch({ offset, limit, sort, filters, signal }) function returns { rows, total }, or { rows, hasMore } when the total is unknown.
The table requests rows in blocks of blockSize as the user scrolls and keeps the last fifty blocks. While a block is loading, placeholders stand in for its rows.
Sorting, filters and search run on the server, and outdated requests are canceled through signal. The totals function returns the totals row.
The values function feeds a list filter: it receives the column key, the filters, a limit and the search text and returns { values, truncated }. With truncated: true the filter says that not every value is listed and offers search.
Without height the table shows data page by page, one request per page. The refresh() method on the table ref clears the cache, and a failed request arrives as the error event. CSV export fetches the whole result a thousand rows per request.
Orders on the server
# | Customer | Amount | |
|---|---|---|---|
Loading orders…
<template> <div class="flex flex-col gap-3"> <NuiInput v-model="quick" type="search" size="sm" class="max-w-64" placeholder="Search customers" aria-label="Search customers" /> <NuiTable v-model:quick="quick" :columns="columns" :source="source" :get-key="keyOf" caption="Orders on the server" height="20rem" /> <p class="m-0 text-sm text-muted-foreground">{{ summary }}</p> </div></template><script setup lang="ts">import { computed, ref } from 'vue';import { NuiInput, plural } from '@numior/kit';import { NuiTable, type NuiTableColumn, type TableFilter, type TableSort, type TableSource,} from '@numior/kit/table';import { ordersOf } from './many-orders';import type { Order } from './orders';const orders = ordersOf(20_000);const SIGN = { asc: 1, desc: -1 } as const;const NO_ORDER: TableSort = { key: '', direction: 'asc' };const compare: Readonly<Record<string, (a: Order, b: Order) => number>> = { id: (a, b) => a.id - b.id, customer: (a, b) => a.customer.localeCompare(b.customer), total: (a, b) => a.total - b.total,};const isQuick = (filter: TableFilter): filter is Extract<TableFilter, { kind: 'quick' }> => filter.kind === 'quick';const found = (filters: readonly TableFilter[]): readonly Order[] => { const text = filters.find(isQuick)?.value.toLowerCase() ?? ''; return orders.filter((order) => order.customer.toLowerCase().includes(text));};const sorted = (rows: readonly Order[], sort: readonly TableSort[]): readonly Order[] => { const [order = NO_ORDER] = sort; const by = compare[order.key]; return by === undefined ? rows : rows.toSorted((a, b) => by(a, b) * SIGN[order.direction]);};const wait = (signal: AbortSignal): Promise<void> => new Promise((resolve, reject) => { const timer = setTimeout(resolve, 300); signal.addEventListener( 'abort', () => { clearTimeout(timer); reject(signal.reason); }, { once: true }, ); });const numbers = new Intl.NumberFormat('en-US');const total = ref<number>();const quick = ref('');const source: TableSource<Order> = { fetch: async ({ offset, limit, sort, filters, signal }) => { await wait(signal); const rows = sorted(found(filters), sort); total.value = rows.length; return { rows: rows.slice(offset, offset + limit), total: rows.length }; },};const columns: NuiTableColumn<Order>[] = [ { key: 'id', label: '#', type: 'number', width: 96, filter: false, value: (row) => row.id, format: (value) => String(value), }, { key: 'customer', label: 'Customer', type: 'text', width: 200, flex: 1, filter: false, value: (row) => row.customer, }, { key: 'total', label: 'Amount', type: 'number', width: 140, filter: false, value: (row) => row.total, },];const summary = computed(() => total.value === undefined ? 'Loading orders…' : `Found ${numbers.format(total.value)} ${plural('en', total.value, { one: 'order', other: 'orders' })}.`,);const keyOf = (order: Order): number => order.id;</script>import { orders, type Order, type OrderLine, type OrderStatus } from './orders';import { pick, seeded, type Random } from './random';const FIRST_ID = 21_000;const LAST_DAY = Date.UTC(2026, 8, 27);const DAY = 86_400_000;const DAYS = 180;const MAX_LINES = 3;const MAX_QUANTITY = 3;const STATUSES: readonly OrderStatus[] = [ 'delivered', 'delivered', 'delivered', 'delivered', 'shipped', 'shipped', 'paid', 'paid', 'pending', 'cancelled',];const LINES = orders.flatMap((order) => order.lines);const upTo = (random: Random, limit: number): number => 1 + Math.floor(random() * limit);const lineOf = (random: Random): OrderLine => ({ ...pick(random, LINES), quantity: upTo(random, MAX_QUANTITY),});const orderOf = (random: Random, index: number): Order => { const buyer = pick(random, orders); const lines = Array.from({ length: upTo(random, MAX_LINES) }, () => lineOf(random)); return { id: FIRST_ID + index, date: new Date(LAST_DAY - Math.floor(random() * DAYS) * DAY).toISOString().slice(0, 10), customer: buyer.customer, city: buyer.city, status: pick(random, STATUSES), payment: pick(random, orders).payment, delivery: pick(random, orders).delivery, manager: pick(random, orders).manager, total: lines.reduce((sum, line) => sum + line.quantity * line.price, 0), lines, };};export const ordersOf = (count: number, seed = 1): Order[] => { const random = seeded(seed); return Array.from({ length: count }, (_, index) => orderOf(random, index));};export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];export type Random = () => number;export const seeded = (seed: number): Random => { let state = seed >>> 0; return () => { state = (state + 0x6d2b79f5) >>> 0; const mixed = Math.imul(state ^ (state >>> 15), state | 1); const spread = mixed ^ (mixed + Math.imul(mixed ^ (mixed >>> 7), mixed | 61)); return ((spread ^ (spread >>> 14)) >>> 0) / 4_294_967_296; };};export const pick = <Item>(random: Random, items: readonly Item[]): Item => { const item = items[Math.floor(random() * items.length)]; if (item === undefined) { throw new RangeError('pick needs a list with items'); } return item;};With v-model:groupBy the server computes the groups: fetch receives the groupBy keys and the groupPath to the expanded group. While the path is shorter than the list of keys, return { groups } with the value, row count and totals of each group. At the last level return the rows of the group.
Groups start collapsed, and the keys of expanded ones are kept in v-model:expanded. While the rows of an expanded group are loading, placeholders stand in for them.
Orders by city
# | Customer | City | Amount | |
|---|---|---|---|---|
Total |
<template> <NuiTable v-model:group-by="groupBy" v-model:expanded="expanded" :columns="columns" :source="source" :get-key="keyOf" caption="Orders by city" height="20rem" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiTable, type NuiTableColumn, type TableNodeId, type TableSource, type TableSourceGroup,} from '@numior/kit/table';import { ordersOf } from './many-orders';import type { Order } from './orders';const orders = ordersOf(20_000);const VALUES: Readonly<Record<string, (order: Order) => string>> = { city: (order) => order.city, customer: (order) => order.customer,};const valueOf = (order: Order, key: string | undefined): string => VALUES[key ?? '']?.(order) ?? '';const groupsOf = (rows: readonly Order[], key: string): TableSourceGroup[] => { const groups = new Map<string, { count: number; total: number }>(); for (const row of rows) { const value = valueOf(row, key); const group = groups.get(value) ?? { count: 0, total: 0 }; groups.set(value, { count: group.count + 1, total: group.total + row.total }); } return [...groups].map(([value, { count, total }]) => ({ value, count, aggregates: { total }, }));};const wait = (signal: AbortSignal): Promise<void> => new Promise((resolve, reject) => { const timer = setTimeout(resolve, 300); signal.addEventListener( 'abort', () => { clearTimeout(timer); reject(signal.reason); }, { once: true }, ); });const sum = orders.reduce((total, order) => total + order.total, 0);const groupBy = ref<readonly string[]>(['city']);const expanded = ref<readonly TableNodeId[]>([]);const source: TableSource<Order> = { fetch: async ({ offset, limit, groupBy: keys, groupPath, signal }) => { await wait(signal); const inside = orders.filter((order) => groupPath.every((value, depth) => valueOf(order, keys[depth]) === value), ); const level = keys[groupPath.length]; return level === undefined ? { rows: inside.slice(offset, offset + limit), total: inside.length } : { groups: groupsOf(inside, level) }; }, totals: async ({ signal }) => { await wait(signal); return { total: sum }; },};const columns: NuiTableColumn<Order>[] = [ { key: 'id', label: '#', type: 'number', width: 96, sortable: false, filter: false, value: (row) => row.id, format: (value) => String(value), }, { key: 'customer', label: 'Customer', type: 'text', width: 200, flex: 1, sortable: false, filter: false, value: (row) => row.customer, }, { key: 'city', label: 'City', type: 'text', width: 140, sortable: false, filter: false, value: (row) => row.city, }, { key: 'total', label: 'Amount', type: 'number', width: 140, sortable: false, filter: false, aggregate: 'sum', value: (row) => row.total, },];const keyOf = (order: Order): number => order.id;</script>import { orders, type Order, type OrderLine, type OrderStatus } from './orders';import { pick, seeded, type Random } from './random';const FIRST_ID = 21_000;const LAST_DAY = Date.UTC(2026, 8, 27);const DAY = 86_400_000;const DAYS = 180;const MAX_LINES = 3;const MAX_QUANTITY = 3;const STATUSES: readonly OrderStatus[] = [ 'delivered', 'delivered', 'delivered', 'delivered', 'shipped', 'shipped', 'paid', 'paid', 'pending', 'cancelled',];const LINES = orders.flatMap((order) => order.lines);const upTo = (random: Random, limit: number): number => 1 + Math.floor(random() * limit);const lineOf = (random: Random): OrderLine => ({ ...pick(random, LINES), quantity: upTo(random, MAX_QUANTITY),});const orderOf = (random: Random, index: number): Order => { const buyer = pick(random, orders); const lines = Array.from({ length: upTo(random, MAX_LINES) }, () => lineOf(random)); return { id: FIRST_ID + index, date: new Date(LAST_DAY - Math.floor(random() * DAYS) * DAY).toISOString().slice(0, 10), customer: buyer.customer, city: buyer.city, status: pick(random, STATUSES), payment: pick(random, orders).payment, delivery: pick(random, orders).delivery, manager: pick(random, orders).manager, total: lines.reduce((sum, line) => sum + line.quantity * line.price, 0), lines, };};export const ordersOf = (count: number, seed = 1): Order[] => { const random = seeded(seed); return Array.from({ length: count }, (_, index) => orderOf(random, index));};export type OrderStatus = 'pending' | 'paid' | 'shipped' | 'delivered' | 'cancelled';export type Payment = 'card' | 'transfer' | 'cash';export type Delivery = 'courier' | 'pickup' | 'post';export interface OrderLine { readonly sku: string; readonly name: string; readonly quantity: number; readonly price: number;}export interface Order { readonly id: number; readonly date: string; readonly customer: string; readonly city: string; readonly status: OrderStatus; readonly payment: Payment; readonly delivery: Delivery; readonly manager: string; readonly total: number; readonly lines: readonly OrderLine[];}export const ORDER_STATUSES: Record<OrderStatus, string> = { pending: 'Awaiting payment', paid: 'Paid', shipped: 'Shipped', delivered: 'Delivered', cancelled: 'Canceled',};export const PAYMENTS: Record<Payment, string> = { card: 'Card', transfer: 'Bank transfer', cash: 'On delivery',};export const DELIVERIES: Record<Delivery, string> = { courier: 'Courier', pickup: 'Pickup', post: 'Mail',};export const orders: readonly Order[] = [ { id: 20401, date: '2026-09-16', customer: 'Peter Wolfe', city: 'Boston', status: 'delivered', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 307, lines: [ { sku: 'S-101', name: 'Oslo armchair', quantity: 1, price: 249 }, { sku: 'X-507', name: 'Linen pillow', quantity: 2, price: 29 }, ], }, { id: 20402, date: '2026-09-17', customer: 'Lena Ortiz', city: 'Chicago', status: 'delivered', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 138, lines: [{ sku: 'L-401', name: 'Nord table lamp', quantity: 2, price: 69 }], }, { id: 20403, date: '2026-09-18', customer: 'Tim Sayed', city: 'Denver', status: 'delivered', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 507, lines: [ { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, { sku: 'S-104', name: 'Bergen chair', quantity: 2, price: 89 }, ], }, { id: 20404, date: '2026-09-19', customer: 'Vera Lane', city: 'Boston', status: 'cancelled', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 180, lines: [{ sku: 'S-110', name: 'Loft stool', quantity: 4, price: 45 }], }, { id: 20405, date: '2026-09-20', customer: 'Glen Nash', city: 'Austin', status: 'delivered', payment: 'cash', delivery: 'post', manager: 'Maria Kim', total: 175, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 1, price: 59 }, { sku: 'X-507', name: 'Linen pillow', quantity: 4, price: 29 }, ], }, { id: 20406, date: '2026-09-21', customer: 'Evan Porter', city: 'Seattle', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 199, lines: [{ sku: 'H-301', name: 'Vik shelving unit', quantity: 1, price: 199 }], }, { id: 20407, date: '2026-09-22', customer: 'Mary Cooper', city: 'Portland', status: 'shipped', payment: 'transfer', delivery: 'post', manager: 'Maria Kim', total: 416, lines: [ { sku: 'L-408', name: 'Arc floor lamp', quantity: 1, price: 119 }, { sku: 'L-412', name: 'Sphere pendant', quantity: 3, price: 99 }, ], }, { id: 20408, date: '2026-09-23', customer: 'Paul Hawkins', city: 'Boston', status: 'shipped', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 368, lines: [ { sku: 'H-305', name: 'Fjord dresser', quantity: 1, price: 299 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], }, { id: 20409, date: '2026-09-24', customer: 'Olga Graham', city: 'Chicago', status: 'paid', payment: 'card', delivery: 'pickup', manager: 'Maria Kim', total: 139, lines: [{ sku: 'T-207', name: 'Tromso coffee table', quantity: 1, price: 139 }], }, { id: 20410, date: '2026-09-25', customer: 'Sam Ellis', city: 'Denver', status: 'paid', payment: 'card', delivery: 'courier', manager: 'Anna Turner', total: 863, lines: [ { sku: 'S-104', name: 'Bergen chair', quantity: 6, price: 89 }, { sku: 'T-201', name: 'Malmo desk', quantity: 1, price: 329 }, ], }, { id: 20411, date: '2026-09-26', customer: 'Nina Hart', city: 'Austin', status: 'pending', payment: 'transfer', delivery: 'courier', manager: 'Maria Kim', total: 498, lines: [{ sku: 'S-101', name: 'Oslo armchair', quantity: 2, price: 249 }], }, { id: 20412, date: '2026-09-27', customer: 'Alina Yusuf', city: 'Portland', status: 'pending', payment: 'card', delivery: 'pickup', manager: 'Anna Turner', total: 187, lines: [ { sku: 'X-501', name: 'Wool throw', quantity: 2, price: 59 }, { sku: 'L-401', name: 'Nord table lamp', quantity: 1, price: 69 }, ], },];export type Random = () => number;export const seeded = (seed: number): Random => { let state = seed >>> 0; return () => { state = (state + 0x6d2b79f5) >>> 0; const mixed = Math.imul(state ^ (state >>> 15), state | 1); const spread = mixed ^ (mixed + Math.imul(mixed ^ (mixed >>> 7), mixed | 61)); return ((spread ^ (spread >>> 14)) >>> 0) / 4_294_967_296; };};export const pick = <Item>(random: Random, items: readonly Item[]): Item => { const item = items[Math.floor(random() * items.length)]; if (item === undefined) { throw new RangeError('pick needs a list with items'); } return item;};To load a tree from the server, set source.children: it gets a row, the sorting, filters and a signal and returns the row's children. Mark rows with children with hasChildren, and the children load when the row is expanded. Grouping does not work in a tree.
While the children are loading, a placeholder shows under the row. CSV export of a tree takes only the top-level rows.
Departments on the server
Department | People | |
|---|---|---|
<template> <NuiTable v-model:expanded="expanded" :columns="columns" :source="source" :get-key="keyOf" :has-children="hasChildren" caption="Departments on the server" height="18rem" /></template><script setup lang="ts">import { ref } from 'vue';import { NuiTable, type NuiTableColumn, type TableNodeId, type TableSource,} from '@numior/kit/table';interface Unit { readonly id: string; readonly name: string; readonly people: number; readonly parent: string | null;}const units: readonly Unit[] = [ { id: 'sales', name: 'Sales', people: 42, parent: null }, { id: 'sales-home', name: 'Home market', people: 18, parent: 'sales' }, { id: 'sales-capital', name: 'Capital', people: 11, parent: 'sales-home' }, { id: 'sales-regions', name: 'Regions', people: 7, parent: 'sales-home' }, { id: 'sales-abroad', name: 'Abroad', people: 24, parent: 'sales' }, { id: 'dev', name: 'Engineering', people: 64, parent: null }, { id: 'dev-web', name: 'Web', people: 38, parent: 'dev' }, { id: 'dev-mobile', name: 'Mobile apps', people: 26, parent: 'dev' }, { id: 'support', name: 'Support', people: 15, parent: null },];const childrenOf = (parent: string | null): Unit[] => units.filter((unit) => unit.parent === parent);const wait = (signal: AbortSignal): Promise<void> => new Promise((resolve, reject) => { const timer = setTimeout(resolve, 300); signal.addEventListener( 'abort', () => { clearTimeout(timer); reject(signal.reason); }, { once: true }, ); });const expanded = ref<readonly TableNodeId[]>([]);const source: TableSource<Unit> = { fetch: async ({ offset, limit, signal }) => { await wait(signal); const roots = childrenOf(null); return { rows: roots.slice(offset, offset + limit), total: roots.length }; }, children: async ({ row, signal }) => { await wait(signal); return childrenOf(row.id); },};const hasChildren = (unit: Unit): boolean => units.some((entry) => entry.parent === unit.id);const columns: NuiTableColumn<Unit>[] = [ { key: 'name', label: 'Department', type: 'text', width: 260, flex: 1, sortable: false, filter: false, value: (row) => row.name, }, { key: 'people', label: 'People', type: 'number', width: 140, sortable: false, filter: false, value: (row) => row.people, },];const keyOf = (unit: Unit): string => unit.id;</script>