Minimal example

Product name
Price
Sprouts - Onion
261.51
Beer - True North Lager
191.32
Milk - Condensed
826.1
Brandy Cherry - Mcguinness
555.07
Olive - Spread Tapenade
506.45
Tea - Black Currant
750.65
Coconut Milk - Unsweetened
658.56
Nut - Walnut, Pieces
763.42
Apple - Northern Spy
81.35
Orange - Canned, Mandarin
939.59
Veal - Brisket, Provimi,bnls
353.49
Wine - Ice Wine
867.85
Table Cloth 54x72 White
703.86
Wine - Cotes Du Rhone Parallele
967.56
Wine - Duboeuf Beaujolais
247.42
Carrots - Jumbo
880.11
Wine - Touraine Azay - Le - Rideau
949.68
Schnappes Peppermint - Walker
879.93
Wine - Champagne Brut Veuve
496.79
Appetizer - Smoked Salmon / Dill
274.6

Features Implemented

  • None
import type { BaseColumn } from "$lib/datagrid/types";
import type { InventoryDataRow } from "$lib/data/inventory";

export const columns = [
    {
        id: 'product.name',
        title: 'Product name',
        sortable: true,
        grow: true,
    },
    {
        id: 'price',
        title: 'Price',
        sortable: true,
    },
] satisfies BaseColumn<InventoryDataRow>[]
<script lang="ts">
	import { setContext } from 'svelte';
	import { columns } from './columns.svelte';
	import { inventoryData as data } from '$lib/data/inventory';

	import { TzezarDatagrid } from '$lib/datagrid/tzezar-datagrid.svelte';
	import * as Datagrid from '$lib/datagrid';

	let datagrid = setContext(
		`datagrid`,
		new TzezarDatagrid({
			data,
			columns,
		})
	);
</script>

<Datagrid.Datagrid>
	{#snippet head()}
		{#each datagrid.columns as column (column.id)}
			<Datagrid.Header {column} />
		{/each}
	{/snippet}
	{#snippet body()}
		{#each datagrid.internal.paginatedData as row, rowIndex}
			<Datagrid.Row {rowIndex}>
				{#each datagrid.columns as column, columnIndex}
					<Datagrid.Cell {columnIndex} {rowIndex} {column} {row} />
				{/each}
			</Datagrid.Row>
		{/each}
	{/snippet}
</Datagrid.Datagrid>