Sorting
Sort table data by column to organize and prioritize information.
Example
Id
Name
Category
Price Retail
Status
1
Practical Plastic Soap
Clothing
255.41
in-stock
2
Intelligent Gold Table
Home & Garden
250.12
in-stock
3
Modern Rubber Cheese
Sports
236.6
in-stock
4
Soft Marble Cheese
Home & Garden
443.87
in-stock
5
Electronic Marble Hat
Beauty
413.91
discontinued
6
Bespoke Bamboo Car
Electronics
1553.96
in-stock
7
Refined Bronze Chicken
Sports
66.97
backordered
8
Handmade Metal Chips
Sports
219.03
low-stock
9
Oriental Steel Bike
Clothing
229.53
backordered
10
Incredible Granite Shirt
Home & Garden
134.63
low-stock
Per page:
Page 1 of 100
Showing
1
to
10
of 1000 rows
{#each datagrid.columns.getLeafColumnsInOrder() as column}
{@render LeafHeader(column)}
{/each}
{#each datagrid.rows.getPaginatedRows() as row}
{#if !row.isGroupRow()}
{#each datagrid.columns.getLeafColumnsInOrder() as column}
{@render RenderBodyCell(column, row)}
{/each}
{:else}{/if}
{/each}
{getCellContent(column, row.original)}
{/if}
{/snippet}
{#snippet LeafHeader(column: LeafColumn)}
{#if column.isVisible()}
datagrid.handlers.sorting.toggleColumnSort(column, e.ctrlKey)}
class={cn(
'th flex min-w-40 max-w-40 items-center justify-between gap-2 px-4 py-2',
column._meta.grow && '!max-w-full !grow',
column.isSortable() && 'cursor-pointer'
)}
style:--width={column.state.size.width + 'px'}
style:--min-width={column.state.size.minWidth + 'px'}
style:--max-width={column.state.size.maxWidth + 'px'}
>
{/if}
{/snippet}
{column.header}
{#if column.isSortable()}
{/if}