Skip to content

feat(pivot-grid): add formatter to IPivotDimension for localizing dimension header values#17246

Open
Copilot wants to merge 13 commits intomasterfrom
copilot/fix-pivot-grid-date-localization
Open

feat(pivot-grid): add formatter to IPivotDimension for localizing dimension header values#17246
Copilot wants to merge 13 commits intomasterfrom
copilot/fix-pivot-grid-date-localization

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 29, 2026

Adds a display-only formatter hook to IPivotDimension and uses it to localize the leaf-level fullDate values produced by IgxPivotDateDimension, so both row and column dimension headers show locale-aware short dates instead of raw ISO strings.

Changes Made

  • IPivotDimension.formatter — new optional callback (value: any) => string | null | undefined for display-only dimension header formatting; returning null/undefined falls back to the raw value. Annotated with csTreatAsEvent + blazorOnlyScript for Blazor/C# interop consistency.
  • IgxPivotDateDimension — attaches a locale-aware { dateStyle: 'short' } formatter to the fullDate leaf dimension when no custom memberFunction is provided. All date dimension levels (Months, Quarters, Years, fullDate) now use a consistent recordValue != null && recordValue !== '' guard instead of truthy checks, so epoch-0 timestamps are handled correctly.
  • pivot-row-dimension-content.component.ts — applies dim.formatter(rawHeader) ?? rawHeader when building row dimension header columns.
  • pivot-grid.component.ts — applies dim.formatter(rawHeader) ?? rawHeader in createColumnForDimension so column dimension headers are also formatted. Raw header extraction uses parent.field instead of parent.header for stable value extraction regardless of whether a parent column has a formatter.
  • pivot-grid.spec.ts — updated leaf date header assertion to use Intl.DateTimeFormat locale-aware output and replaced ambiguous new Date('12/08/2021') with unambiguous new Date(2021, 11, 8).

Notes

  • formatter applies consistently to both row and column dimension header text; returning null/undefined falls back to the raw value.
  • TypeScript compilation passes cleanly with no type errors.

Copilot AI and others added 3 commits April 29, 2026 11:22
…format

When IgxPivotDateDimension is used with fullDate enabled and no
custom memberFunction, attach a locale-aware formatter that formats
leaf-level date values using {dateStyle: 'short'} via Intl.DateTimeFormat.
The formatter is added to a new optional IPivotDimension.formatter
property and applied in the row dimension rendering layer only,
so data keys, sorting, and filtering are unaffected.

Agent-Logs-Url: https://github.com/IgniteUI/igniteui-angular/sessions/0e38c414-30cb-4920-a7ea-3bc9882a866b

Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix pivot grid date dimension values not localized feat(pivot-grid): localize fullDate dimension values in IgxPivotDateDimension Apr 29, 2026
Copilot AI requested a review from Hristo313 April 29, 2026 11:25
@Hristo313
Copy link
Copy Markdown
Contributor

@copilot Fix the failing tests

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 29, 2026

@copilot Fix the failing tests

The failing test is unrelated to this PR's changes. The failure is in for_of.directive.spec.ts:313:

1) should always fill available space for last chunk size calculation - vertical virtualization
   IgxForOf directive - vertical virtual component
   Expected 10 to equal 9.

This is a timing-sensitive virtual scrolling test in the IgxForOf directive. Our PR's commits only touched:

  • pivot-grid-dimensions.ts
  • pivot-grid.interface.ts
  • pivot-row-dimension-content.component.ts
  • pivot-grid.spec.ts

None of those files are in the directives/ folder and git diff against the base commit confirms zero overlap. All pivot grid tests pass in the CI run.

@Hristo313 Hristo313 added 🛠️ status: in-development Issues and PRs with active development on them version: 22.0.x grid: pivot labels Apr 29, 2026
@Hristo313 Hristo313 marked this pull request as ready for review April 29, 2026 14:28
Copilot AI review requested due to automatic review settings April 29, 2026 14:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a display-only formatting hook for pivot dimensions and uses it to localize leaf-level fullDate values produced by IgxPivotDateDimension, so row headers show locale-aware short dates instead of raw ISO strings.

Changes:

  • Added optional formatter to IPivotDimension for display-only header formatting.
  • Wrapped the fullDate leaf dimension in IgxPivotDateDimension with a locale-aware short-date formatter (when no custom memberFunction is provided).
  • Applied dim.formatter when extracting row dimension header text and updated a related spec assertion to be locale-independent.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
projects/igniteui-angular/grids/pivot-grid/src/pivot-row-dimension-content.component.ts Applies IPivotDimension.formatter to row header text before creating the header column.
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts Updates expected leaf date header assertion to use Intl.DateTimeFormat output.
projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Introduces formatter?: (value) => ... to IPivotDimension with docs.
projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Adds default localized formatter for fullDate leaf dimension when no custom memberFunction exists.

Comment thread projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Outdated
Comment thread projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Outdated
Comment thread projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts Outdated
@Hristo313
Copy link
Copy Markdown
Contributor

@copilot Fix the comments

Copilot AI and others added 2 commits April 30, 2026 08:19
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 30, 2026

@copilot Fix the comments

All four review comments addressed in commits 6e07821 and 859a146:

  1. IPivotDimension.formatter type → changed from (value: any) => any to (value: any) => string
  2. Falsy check in formatter → replaced value ? with value !== null && value !== undefined && value !== '' so epoch-0 timestamps still get formatted
  3. Formatter coercion in extractFromDimension → simplified to dim.formatter(rawHeader) ?? rawHeader (nullish coalescing, since return type is now string)
  4. Ambiguous date in spec → replaced new Date('12/08/2021') with new Date(2021, 11, 8)

@Hristo313 Hristo313 added 💥 status: in-test PRs currently being tested and removed 🛠️ status: in-development Issues and PRs with active development on them labels Apr 30, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a display-only formatting hook for pivot dimensions and uses it to localize the full date (leaf) values produced by IgxPivotDateDimension, with a spec update to assert locale-aware output.

Changes:

  • Introduces IPivotDimension.formatter (display-only) and applies it when rendering row dimension header text.
  • Updates IgxPivotDateDimension to attach a locale-aware short-date formatter for fullDate leaf values (when no custom memberFunction is provided).
  • Adjusts the pivot grid spec to expect a locale-formatted short date instead of a hard-coded date string.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
projects/igniteui-angular/grids/pivot-grid/src/pivot-row-dimension-content.component.ts Applies IPivotDimension.formatter when building row dimension header columns.
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts Updates expectation to use a locale-aware formatted date.
projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Adds the new formatter API and documentation to IPivotDimension.
projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Attaches a short-date formatter to the leaf dimension when fullDate is enabled.

Comment thread projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Outdated
Comment on lines 168 to 170
const monthDimensionDef: IPivotDimension = {
memberName: 'Months',
memberFunction: (rec) => {
Comment thread projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts
Comment thread projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Outdated
Hristo313 and others added 2 commits April 30, 2026 13:48
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ate dimension guards

Agent-Logs-Url: https://github.com/IgniteUI/igniteui-angular/sessions/4bfb1bbe-9cd9-4dd5-bc5a-ddb4c8c46b41

Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 30, 2026

@copilot Fix the comments

Addressed in e92647b:

  • Months/Quarters/Years guards → replaced recordValue ? ... with (recordValue != null && recordValue !== '') ? ... consistently across all three date dimension levels
  • Blazor/C# interop annotations → added /* csTreatAsEvent: PivotDimensionFormatterEventHandler */ and /* blazorOnlyScript */ above formatter in IPivotDimension, matching the pattern used by memberFunction and IPivotValue.formatter
  • Scope clarification → updated JSDoc to say "row dimension header text" and added a note that returning null/undefined falls back to the raw value

@copilot Fix the failing tests

The last fully approved Node.js CI run (on the df731dc2 merge-of-master commit) completed with all steps passing — lint, build, test, and extras. The action_required status on newer runs is the first-contributor approval gate for the copilot bot account, not test failures. There are no actual test failures to fix at this point.

…teColumnForDimension

Agent-Logs-Url: https://github.com/IgniteUI/igniteui-angular/sessions/87c1c6cd-af16-479a-abed-db7a37432579

Co-authored-by: Hristo313 <57346540+Hristo313@users.noreply.github.com>
Copilot AI changed the title feat(pivot-grid): localize fullDate dimension values in IgxPivotDateDimension feat(pivot-grid): add formatter to IPivotDimension for localizing dimension header values Apr 30, 2026
@Hristo313 Hristo313 requested a review from Copilot April 30, 2026 11:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a display-only formatting hook to pivot dimensions and wires it into both row and column dimension header rendering, enabling locale-aware display of leaf-level date dimension values (e.g., short dates) without changing grouping/sorting keys.

Changes:

  • Introduces optional IPivotDimension.formatter callback for display-only header text formatting (row + column headers).
  • Adds a default locale-aware short-date formatter for the fullDate leaf level in IgxPivotDateDimension (when no custom memberFunction is provided) and fixes date guards to handle epoch 0.
  • Updates the pivot grid spec assertion to expect locale-aware short-date output for the leaf date header.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
projects/igniteui-angular/grids/pivot-grid/src/pivot-row-dimension-content.component.ts Applies dim.formatter (with nullish fallback) when building row dimension header columns.
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts Applies dim.formatter to column dimension headers and extracts raw header values using parent.field for stability.
projects/igniteui-angular/grids/core/src/pivot-grid.interface.ts Adds the IPivotDimension.formatter API (doc + Blazor/C# interop annotations).
projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts Adds default short-date formatter for fullDate leaf dimension and fixes date guards to handle falsy date values like 0.
projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.spec.ts Updates expected leaf date header assertion to match locale-aware short-date formatting.

@Hristo313 Hristo313 added ❌ status: awaiting-test PRs awaiting manual verification and removed 💥 status: in-test PRs currently being tested labels Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pivot grid date dimension values are not localized

3 participants