Skip to main content
Version: 1.0.7

buildGroups

@spartanfx/react v1.0.7


@spartanfx/react / buildGroups

Function: buildGroups()

buildGroups<T>(items, groupByLevel1?, groupByLevel2?, groupByLevel3?, defaultCollapsed?, formatters?): IGroupingResult<T>

Build a Fluent UI IGroup[] hierarchy from a flat items array.

Items are stable-sorted by the group fields (level1, then level2, then level3) so that the returned sortedItems array matches the startIndex/count references in the IGroup tree.

Type Parameters

T

T

Parameters

items

T[]

Flat array of data items

groupByLevel1?

string

Field name for top-level grouping

groupByLevel2?

string

Field name for second-level grouping (optional)

groupByLevel3?

string

Field name for third-level grouping (optional)

defaultCollapsed?

boolean

Whether groups start collapsed (default: false)

formatters?

FieldFormatters<T>

Optional map of field names to formatter functions (from column onGetFormattedValue)

Returns

IGroupingResult<T>

Sorted items and matching IGroup[] hierarchy