Skip to content
Data TableAPI Reference

Row grouping options and events

comins-table@0.2.2React

Single-depth grouping with parent-owned groups, membership, and expansion. Distinct from tree children. The explicit groups array determines group order.

Grouping and selection example

groups: readonly TGroup[];

Required group definitions. Empty groups remain visible; sorting applies to rows within each group.

getGroupId: (group: TGroup) => CominsRowId;

Required stable unique group ID.

getRowGroupId: (row: TData, dataIndex: number) => CominsRowId;

Required resolver from source row and dataIndex to its group ID.

getGroupLabel?: (group: TGroup) => React.ReactNode;

Group-header label; defaults to the string form of the group ID.

expandedGroupIds?: readonly CominsRowId[];

Parent-owned expanded group IDs. Defaults to an empty array; update via onChangeExpandedGroupIds.

onChangeExpandedGroupIds?: (groupIds: CominsRowId[]) => void;

Reports the full next ID array on expansion/collapse requests. Apply it to update the view.

aggregations?: Readonly<Partial<Record<string, CominsRowGroupAggregation>>>;

avg/count/max/min/sum by column ID. None when omitted. With filtering, aggregates only filtered group members.

renderGroupContent?: (params: CominsRowGroupRenderParams<TData, TGroup>) => React.ReactNode;

Custom group-header content; omission uses the built-in label/count presentation.

getGroupRowProps?: (params: CominsRowGroupRenderParams<TData, TGroup>) => CominsRowGroupProps | undefined;

Returns className/style for a group row, separate from ordinary rowProps.

groupDraggable?: boolean;

Default false. Enables group reordering; update the parent array through onChangeGroups.

onChangeGroups?: (groups: TGroup[], details: CominsRowGroupMoveDetails) => void;

Receives the new group array and move details. Separate from row-data changes.

setRowGroupId?: (params: CominsSetRowGroupIdParams<TData>) => TData;

Returns a row with updated membership for a cross-group move. Do not mutate the original. Apply data through onChangeData.

export type CominsRowGroupRenderParams<TData, TGroup> = {
aggregateValues: Readonly<Record<string, number | null>>;
expanded: boolean;
group: TGroup;
groupId: CominsRowId;
groupIndex: number;
isEmpty: boolean;
rowCount: number;
};

groupIndex is the position in groups; rowCount and aggregateValues describe current group members.

export type CominsRowGroupMoveDetails = {
fromIndex: number;
groupId: CominsRowId;
reason: "move";
targetGroupId: CominsRowId;
toIndex: number;
};

Group reorder result. fromIndex/toIndex are group-array indexes; reason is move.

export type CominsSetRowGroupIdParams<TData> = {
fromGroupId: CominsRowId;
row: TData;
rowId: CominsRowId;
toGroupId: CominsRowId;
};

fromGroupId/toGroupId identify the membership change. Return a row containing the new group field.

label?: {
render?: (group: TGroup) => React.ReactNode;
};

See the 0.2.2 migration guide for rendering precedence and return values.

content?: {
render?: (params: CominsRowGroupRenderParams<TData, TGroup>) => React.ReactNode;
};

See the 0.2.2 migration guide for rendering precedence and return values.