Skip to content

Add resetRowNumbers grouping flag to Grid#1299

Merged
mstijak merged 1 commit into
masterfrom
feat/grid-reset-row-numbers-per-group
Jun 2, 2026
Merged

Add resetRowNumbers grouping flag to Grid#1299
mstijak merged 1 commit into
masterfrom
feat/grid-reset-row-numbers-per-group

Conversation

@mstijak

@mstijak mstijak commented Jun 2, 2026

Copy link
Copy Markdown
Member

Summary

Adds a per-grouping-level resetRowNumbers flag to Grid. When set on a grouping level, the automatic cxe-grid-row-number column restarts numbering from 1 at the beginning of each group instead of counting continuously across the whole grid.

grouping={[
   { key: { continent: { bind: "$record.continent" } }, showCaption: true, resetRowNumbers: true },
]}
columns={[
   { header: "#", defaultWidth: 50, children: <div class="cxe-grid-row-number" /> },
   // ...
]}

Implementation

The row-number column is a pure CSS counter: the grid container does counter-reset: cx-row-number <start> and each .cxe-grid-row-number::after does counter-increment. The container reset is document-global isolation — without it, two grids on the same page would continue each other's numbering.

The non-obvious part: a counter-reset placed on the group caption row creates a nested counter that is shadowed by the container's reset, so the following data rows ignore it (numbering stays continuous). Using counter-set on the caption instead updates the existing in-scope counter in place, which correctly resets per group while keeping the container reset for cross-grid isolation. Verified in the browser across multiple groups and against a preceding row-numbered grid.

Because the reset rides on the caption row, the grouping level must render a caption (showCaption or caption) for it to take effect — documented.

Changes

  • packages/cx/src/widgets/grid/Grid.tsxresetRowNumbers?: boolean on GridGroupingConfig; renderGroupHeader adds a reset-row-numbers state mod to the group-caption <tbody>.
  • packages/cx/src/widgets/grid/Grid.scss — caption rule counter-set: cx-row-number 0.
  • homedocs/ — new "Per-Group Row Numbers" docs section + example, config-table row, and changelog entry.

Test plan

  • Verified live in the docs example: Asia 1‑2, Europe 1‑3, North America 1‑3.
  • Confirmed cross-grid isolation still holds (group reset does not leak the counter from a preceding grid).

Restarts the automatic cxe-grid-row-number column from 1 at the start of
each group. The grouping caption row uses counter-set (not counter-reset)
so it updates the existing row-number counter in place; counter-reset would
create a nested counter shadowed by the container's reset and the following
data rows would ignore it. The container reset is kept for cross-grid
isolation. Requires the grouping level to render a caption.

Includes docs section, example, and changelog entry.
@mstijak mstijak merged commit b9ae920 into master Jun 2, 2026
2 checks passed
@mstijak mstijak deleted the feat/grid-reset-row-numbers-per-group branch June 2, 2026 10:08
@mstijak mstijak mentioned this pull request Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant