groupItems

DataTable
stable

Recursively groups an array of data table rows by one or more property keys. Each level produces an array of IDataTableGroup objects that carry depth, id, key, value, and the nested items. Used internally by OrigamDataTable grouping.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

items
required
Array<T>
The flat list of data table rows to group.
groupBy
required
Array<string>
Ordered list of property paths to group by. The first element is the outermost grouping level.
depth
number
0
Current recursion depth. Start at 0 (default) for the outermost call.
prefix
string
'root'
Prefix used to build stable unique group ids. Defaults to "root".

API

Return value

The value returned by this util.

A nested array of group descriptors. Returns an empty array when groupBy is empty.

Usage

Examples

Ready-to-paste usage snippets.

Single-level grouping

typescript