Skip to content
Data TableExamples

Group expansion and data-row selection

comins-table@0.2.2React

Inspect explicit group order, aggregates, and retained data-row selection in collapsed groups.

Action Expected result
Initial view East: 2 rows/sum 200; Empty: 0 rows; West: 1 row/sum 240.
Select first data row Selects Alpha, the first leaf, skipping synthetic group rows.
Fold East Hides Alpha/Beta while retaining alpha in selection and sum 200.
getSelectedRows Displays selected business IDs in the last-read retrieved field.
Expand East Shows Alpha/Beta without recreating the selection.
Reverse groups Changes order to West → Empty → East; row IDs and membership remain intact.
Reset Restores initial group order and expansion, and clears selection.

You can also use group disclosure buttons and click business rows according to the existing Row Selection rules.

The application owns groups and expandedGroupIds. Connect onChangeExpandedGroupIds to accept UI and ref expansion requests. The example uses setGroups to reorder the explicit group array without duplicating order fields inside group objects.

setSelectedRow(0) addresses a visible data leaf, excluding group headings. The index depends on sorting and expansion, so do not persist it as identity. Use the ID provided by getRowId for stable identity.

Selection in a collapsed group remains dormant. The example separately displays row IDs received by onChangeSelection and business data queried through getSelectedRows(). Table owns this selection state; the observed IDs are not injected back as a controlled selection prop.

The example uses aggregations: { amount: "sum" }. Collapsing a group does not remove its members, so aggregate inputs remain. Empty stays visible because it exists in groups; the example displays — when no numeric sum exists. renderGroupContent renders only the inner label, count, and aggregate; the package owns the outer row and disclosure.

This is single-depth CSR grouping. It does not include Group selection, Tree, pagination, or remote loading. Group/Row Drag and filtering/Summary combinations remain separate scenarios.

Row grouping guide · Expansion methods · Read selection