Fix: Pivot Grid auto-detects date fields from timestamps and date strings #16368
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.
Problem
When using the Pivot Grid with
autoGenerateConfig: true, date fields represented as timestamps (e.g.,1577829600000) or string values (e.g.,"2008-06-20","10/24/2025") were not recognized asDateobjects during initialization.As a result, the
autoGenerateConfiglogic did not create anIgxPivotDateDimensionfor such fields, and they were not automatically assigned as Row Dimensions as specified in the component's behavior specification.Example of the Issue
In the above example, the
Datefield would be skipped during auto-configuration, preventing proper date hierarchy grouping (All Periods → Year → Month → Full Date).Solution
Enhanced the Pivot Grid's auto-generation logic to:
Detect date-like values during type resolution
Leverage on-demand parsing for optimal performance
IgxPivotDateDimensionhandles conversion vianew Date()when values are displayedAutomatically configure as
IgxPivotDateDimensionChanges Made
1. Enhanced Type Detection (
grid-base.directive.ts)Added
isValidTimestamp()method to detect valid timestampsAdded
isValidDateString()method to detect date strings"2008-06-20""10/24/2025""2020/12/31","12-31-2020", etc.Updated
resolveDataTypes()to use these detection methods2. Optimized Configuration Generation (
pivot-grid.component.ts)generateConfig()to detect date fields and createIgxPivotDateDimensionIgxPivotDateDimension's built-in on-demand conversion3. Comprehensive Testing (
pivot-grid.spec.ts)Added 6 new test cases covering:
Result
Date fields are now properly detected and configured regardless of their initial format:
The Pivot Grid will:
IgxPivotDateDimensionautomatically (values parsed on-demand)Supported Date Formats
1577829600000"2008-06-20","2020-12-31""10/24/2025","6/20/2008""2020/12/31","12-31-2020""Jan 1, 2020"Performance
Optimized for large datasets:
Breaking Changes
None. This is a pure enhancement that improves existing functionality without changing any existing behavior for data already provided as Date objects.
Testing
Fixes #16366
Original prompt
Fixes #16366
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.