Rows from a loader
loader receives the query (page, page size, sorting, search, filters and the builder for the backend) and returns { rows, total }; the table shows the loading and keeps only the newest answer. The first page comes from the load of the page (rows and total), so it is not loaded twice. searchColumns adds the search field: the text reaches the query as an ilike on those columns.
| Davide Neri | Colour | 09/01/2026, 05:30 PM | €79.00 |
| Simone Bianchi | Cut | 09/01/2026, 05:00 PM | €28.00 |
| Simone Costa | Balayage | 09/01/2026, 09:30 AM | €120.00 |
| Matteo Marini | Cut | 09/01/2026, 03:30 PM | €43.00 |
| Luca Galli | Cut | 09/01/2026, 02:00 PM | €43.00 |
| Elena Bianchi | Colour | 09/01/2026, 02:00 PM | €79.00 |
| Chiara Greco | Cut and beard | 09/02/2026, 02:00 PM | €52.00 |
| Marco Conti | Cut | 09/02/2026, 03:00 PM | €43.00 |
| Simone Bianchi | Colour | 09/02/2026, 12:30 PM | €64.00 |
| Luca Neri | Balayage | 09/02/2026, 03:00 PM | €130.00 |
| Laura Neri | Colour | 09/02/2026, 09:30 AM | €69.00 |
| Marco Bianchi | Colour | 09/02/2026, 03:00 PM | €69.00 |
| Marco Ferri | Colour | 09/03/2026, 05:30 PM | €69.00 |
| Anna Costa | Colour | 09/03/2026, 05:30 PM | €79.00 |
| Laura Conti | Cut and beard | 09/03/2026, 03:30 PM | €42.00 |
| Luca Marini | Balayage | 09/03/2026, 04:00 PM | €125.00 |
| Davide Moretti | Blow-dry | 09/03/2026, 11:30 AM | €40.00 |
| Chiara Marini | Blow-dry | 09/03/2026, 12:00 PM | €30.00 |
| Paolo Moretti | Cut | 09/04/2026, 02:30 PM | €38.00 |
| Luca Fontana | Colour | 09/04/2026, 12:30 PM | €64.00 |
Code
<script lang="ts">
import { DataTable, type TableColumn } from '@likable-hair/svelte';
import { fetchBookings, queryBookings, searchColumns, type Booking } from './bookings.js';
const first = queryBookings({ page: 1, pageSize: 20 });
const columns: TableColumn<Booking>[] = [
{ key: 'client', label: 'Client', sortable: true },
{ key: 'service', label: 'Service', sortable: true },
{ key: 'start', label: 'Date', type: 'datetime', sortable: true },
{ key: 'amount', label: 'Amount', type: 'number', numberFormat: { style: 'currency', currency: 'EUR' }, sortable: true }
];
</script>
<DataTable
caption="Bookings"
{columns}
rows={first.rows}
total={first.total}
loader={fetchBookings}
{searchColumns}
/>