Grouping data
Organize and group data within your table for improved readability and structure.
Example
Id
Name
Category
Price Retail
Status
1
Sleek Plastic Computer
Beauty
114.71
low-stock
2
Generic Bronze Towels
Clothing
215.7
in-stock
3
Incredible Granite Chair
Home & Garden
372.47
discontinued
4
Oriental Metal Pants
Electronics
490.23
backordered
5
Fantastic Ceramic Bacon
Sports
260.04
low-stock
6
Luxurious Ceramic Gloves
Clothing
477.12
low-stock
7
Gorgeous Steel Bacon
Home & Garden
267.37
discontinued
8
Tasty Silk Fish
Electronics
1722.59
in-stock
9
Fresh Silk Shoes
Electronics
1404.24
low-stock
10
Practical Aluminum Mouse
Electronics
1948.73
in-stock
Per page:
Page 1 of 100
Showing
1
to
10
of 1000 rows
{ "activeGroups": [] }
{#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}
{#each datagrid.columns.getLeafColumnsInOrder() as column, columnIndex (column.columnId)}
{@render RenderGroupCell(column, row)}
{/each}
{/if}
{/each}
{JSON.stringify( { activeGroups: datagrid.features.grouping.activeGroups }, null, 2 )}
{getCellContent(column, row.original)}
{/snippet}
{#snippet RenderGroupCell(column: LeafColumn, row: GridGroupRow)}
{#if column.columnId == row.groupKey}
{@render GroupCellHeaderSnippet(column, row)}
{:else if row.aggregations.some((agg) => agg.columnId === column.columnId)}
{@render GroupCellAggregationSnippet(row, column)}
{/if}
{/snippet}
{#snippet GroupCellHeaderSnippet(column: LeafColumn, row: GridGroupRow)}
{/snippet}
{#snippet GroupCellAggregationSnippet(row: GridGroupRow, column: LeafColumn)}
{#each row.aggregations.filter((agg) => agg.columnId === column.columnId) as aggregation}
{/snippet}
{#snippet LeafHeader(column: LeafColumn)}
{#if column.isVisible()}
{aggregation.type}: {#if aggregation.type === 'percentChange'} {aggregation.value.toFixed(2)}% {:else if typeof aggregation.value === 'number'} {aggregation.value.toLocaleString()} {:else} {aggregation.value} {/if}
{/each}
{column.header}