Grouping data
Organize and group data within your table for improved readability and structure.
Example
Id
Name
Category
Price Retail
Status
1
Oriental Silk Bacon
Home & Garden
351.72
in-stock
2
Gorgeous Gold Fish
Home & Garden
70
in-stock
3
Ergonomic Plastic Cheese
Sports
25.47
backordered
4
Oriental Bronze Shirt
Electronics
659.57
discontinued
5
Fresh Ceramic Sausages
Electronics
1430.55
in-stock
6
Soft Steel Mouse
Sports
221.6
low-stock
7
Ergonomic Steel Mouse
Sports
299.3
in-stock
8
Modern Ceramic Table
Home & Garden
274.36
in-stock
9
Sleek Concrete Car
Clothing
124.56
in-stock
10
Refined Plastic Towels
Electronics
1695.04
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}