diff --git a/src/routes/(dashboard)/columns.ts b/src/routes/(dashboard)/columns.ts index 3665315..19a5233 100644 --- a/src/routes/(dashboard)/columns.ts +++ b/src/routes/(dashboard)/columns.ts @@ -4,10 +4,6 @@ import type { ColumnDef } from '@tanstack/table-core'; import DataTableActions from './data-table-actions.svelte'; export const columns: ColumnDef[] = [ - { - accessorKey: 'id', - header: 'internal_id' - }, { accessorKey: 'type', header: 'Type' @@ -41,8 +37,8 @@ export const columns: ColumnDef[] = [ header: 'Toggle State', cell: ({ row }) => { return renderComponent(DataTableActions, { - id: row.getVisibleCells()[0].getValue() as number, - type: row.getVisibleCells()[1].getValue() as PersonType + id: row.original.id, + type: row.original.type }); }, enableSorting: false diff --git a/src/routes/(dashboard)/data-table.svelte b/src/routes/(dashboard)/data-table.svelte index 30cbb52..92182c2 100644 --- a/src/routes/(dashboard)/data-table.svelte +++ b/src/routes/(dashboard)/data-table.svelte @@ -60,38 +60,36 @@ {#each table.getHeaderGroups() as headerGroup (headerGroup.id)} - {#each headerGroup.headers as header, idx (header.id)} - {#if idx !== 0} - - {#if !header.isPlaceholder} -
{ + {#each headerGroup.headers as header (header.id)} + + {#if !header.isPlaceholder} +
{ + header.column.toggleSorting(); + }} + onkeydown={(e) => { + if (e.key === 'Enter' || e.key === ' ') { header.column.toggleSorting(); - }} - onkeydown={(e) => { - if (e.key === 'Enter' || e.key === ' ') { - header.column.toggleSorting(); - } - }} - > - - {#if header.column.getIsSorted() === 'asc'} - - {:else if header.column.getIsSorted() === 'desc'} - - {:else} - - {/if} -
- {/if} -
- {/if} + } + }} + > + + {#if header.column.getIsSorted() === 'asc'} + + {:else if header.column.getIsSorted() === 'desc'} + + {:else} + + {/if} +
+ {/if} +
{/each}
{/each} @@ -99,12 +97,10 @@ {#each table.getRowModel().rows as row (row.id)} - {#each row.getVisibleCells() as cell, idx (cell.id)} - {#if idx !== 0} - - - - {/if} + {#each row.getVisibleCells() as cell (cell.id)} + + + {/each} {:else}