Footer

Published at Oct 15, 2024

Barcode
Location
Category
Quantiy
Weight
3056519006086
Apt 1819
furniture
972
25.6
6861816867653
Suite 11
furniture
38
52.5
4697486394862
Apt 767
furniture
714
22.1
1507651383044
Suite 47
electronics
212
49.5
3050521118264
Room 1868
furniture
509
23.5
7247654023537
Room 1846
clothing
848
88.6
6687435198303
PO Box 75154
electronics
149
89
2530797670037
PO Box 39137
furniture
147
8.3
7524918686628
Room 1284
clothing
950
33.9
3209383758542
18th Floor
furniture
200
4
4885399982401
Suite 20
electronics
226
34.4
9040207608954
10th Floor
clothing
618
3.2
4481430085015
Suite 25
furniture
770
29.1
6570375480662
Suite 73
clothing
435
16
4677591243156
Apt 572
clothing
105
18.4
1477064628428
Room 1965
furniture
350
10.8
8748415132296
Apt 110
electronics
290
25.8
5101093419413
Room 139
clothing
69
80.4
3108485537297
Room 1571
clothing
201
49.2
9628053961836
Suite 97
electronics
856
13.8
6535041524461
Room 1175
furniture
347
7.1
5767475528475
Apt 1002
furniture
315
4.4
6031765461689
19th Floor
electronics
899
15.9
4767601862362
Apt 721
electronics
641
10.7
8115799619574
PO Box 56865
furniture
380
50.7
9709944090266
PO Box 66553
furniture
970
13.5
9665918579731
Suite 56
electronics
215
8.6
5102624452456
Suite 72
clothing
689
55.9
9692038017354
PO Box 41696
furniture
761
62.4
3846275229597
Apt 1778
clothing
442
5
2827816987163
Apt 1905
clothing
916
2.2
8932948105447
Apt 139
electronics
419
17.3
7421151233239
17th Floor
clothing
652
33.5
9311140697669
Suite 28
electronics
825
92.1
5659027932222
Apt 910
furniture
860
29.7

Implementation

options: {
	footer: { display: true }
}

Code

Datagrid component

<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: data.slice(0, 35),
			columns,
			options: {
				pagination: { display: false },
				footer: { display: true }
			}
		})
	);
</script>

<Datagrid.Datagrid class={{wrapper: 'max-h-[600px]'}}>
	{#snippet head()}
		{#each datagrid.columns as column (column.id)}
			<Datagrid.Header {column} />
		{/each}
	{/snippet}
	{#snippet body()}
		{#each datagrid.data as row, rowIndex}
			<Datagrid.Row {rowIndex}>
				{#each datagrid.columns as column, columnIndex}
					<Datagrid.Cell {column} {row} {columnIndex} {rowIndex} />
				{/each}
			</Datagrid.Row>
		{/each}
	{/snippet}
</Datagrid.Datagrid>

Barcode
Location
Category
Quantiy
Weight
3056519006086
Apt 1819
furniture
972
25.6
6861816867653
Suite 11
furniture
38
52.5
4697486394862
Apt 767
furniture
714
22.1
1507651383044
Suite 47
electronics
212
49.5
3050521118264
Room 1868
furniture
509
23.5
7247654023537
Room 1846
clothing
848
88.6
6687435198303
PO Box 75154
electronics
149
89
2530797670037
PO Box 39137
furniture
147
8.3
7524918686628
Room 1284
clothing
950
33.9
3209383758542
18th Floor
furniture
200
4
4885399982401
Suite 20
electronics
226
34.4
9040207608954
10th Floor
clothing
618
3.2
4481430085015
Suite 25
furniture
770
29.1
6570375480662
Suite 73
clothing
435
16
4677591243156
Apt 572
clothing
105
18.4
1477064628428
Room 1965
furniture
350
10.8
8748415132296
Apt 110
electronics
290
25.8
5101093419413
Room 139
clothing
69
80.4
3108485537297
Room 1571
clothing
201
49.2
9628053961836
Suite 97
electronics
856
13.8
Showing 0 : 20 of 20
CUSTOM FOOTER
Page 1

Implementation

options: {
	footer: { display: true }
}

and place it into footer snippet

{#snippet footer()}
	<div data-datagrid-footer-identifier={datagrid.identifier}>
		FOOTER CONTENT
	</div>
{/snippet}

Add data-datagrid-footer-identifier={datagrid.identifier}

Code

Datagrid component

<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: data.slice(0, 20),
			columns,
			options: {
				pagination: { display: false },
				footer: { display: true }
			}
		})
	);
</script>

<Datagrid.Datagrid>
	{#snippet head()}
		{#each datagrid.columns as column (column.id)}
			<Datagrid.Header {column} />
		{/each}
	{/snippet}
	{#snippet body()}
		{#each datagrid.data as row, rowIndex}
			<Datagrid.Row {rowIndex}>
				{#each datagrid.columns as column, columnIndex}
					<Datagrid.Cell {column} {row} {columnIndex} {rowIndex} />
				{/each}
			</Datagrid.Row>
		{/each}
	{/snippet}
	{#snippet footer()}
		<div
			class="grid grid-cols-3 items-center p-2 pl-3"
			data-datagrid-footer-identifier={datagrid.identifier}
		>
			<span>
				Showing {datagrid.state.processedData.length * datagrid.state.pagination.page -
					datagrid.state.pagination.perPage}
				:
				{datagrid.state.processedData.length * datagrid.state.pagination.page}
				of
				{datagrid.state.pagination.count}
			</span>
			<div class="flex items-center justify-center">CUSTOM FOOTER</div>
			<span class="flex justify-end">Page {datagrid.state.pagination.page}</span>
		</div>
	{/snippet}
</Datagrid.Datagrid>
In the coming days, the grid will officially launch its version 1.0. I recommend waiting until the release before incorporating it into your projects, as we've completely rewritten and simplified the internal logic, making it more efficient. Version 1.0 will also introduce exciting new features such as row grouping and aggregation. If you have any questions or feedback, feel free to reach out! If you find this project valuable, please consider giving it a star on GitHub. Thank you for your support! ❤️