Add resetRowNumbers grouping flag to Grid#1299
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a per-grouping-level
resetRowNumbersflag toGrid. When set on a grouping level, the automaticcxe-grid-row-numbercolumn restarts numbering from 1 at the beginning of each group instead of counting continuously across the whole grid.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::afterdoescounter-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-resetplaced 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). Usingcounter-seton 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 (
showCaptionorcaption) for it to take effect — documented.Changes
packages/cx/src/widgets/grid/Grid.tsx—resetRowNumbers?: booleanonGridGroupingConfig;renderGroupHeaderadds areset-row-numbersstate mod to the group-caption<tbody>.packages/cx/src/widgets/grid/Grid.scss— caption rulecounter-set: cx-row-number 0.homedocs/— new "Per-Group Row Numbers" docs section + example, config-table row, and changelog entry.Test plan