diff --git a/projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts b/projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts index 96efe72ff2a..a0ee52c9459 100644 --- a/projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts +++ b/projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts @@ -106,6 +106,8 @@ export class IgxPivotDateDimension implements IPivotDimension { public childLevel?: IPivotDimension; /** @hidden @internal */ public memberName = 'AllPeriods'; + /** @hidden @internal */ + public locale?: string; public displayName: string; private _resourceStrings: IGridResourceStrings = null; private _baseDimension: IPivotDimension; @@ -145,7 +147,7 @@ export class IgxPivotDateDimension implements IPivotDimension { memberFunction: (rec) => { const recordValue = PivotUtil.extractValueFromDimension(inBaseDimension, rec); const dateValue = recordValue ? getDateFormatter().createDateFromValue(recordValue) : null; - return recordValue ? getDateFormatter().formatDateTime(dateValue, undefined, { month: 'long'}) : rec['Months']; + return recordValue ? getDateFormatter().formatDateTime(dateValue, this.locale, { month: 'long'}) : rec['Months']; }, enabled: true, childLevel: baseDimension diff --git a/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts b/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts index aebbdbb6831..bd27f64e0d2 100644 --- a/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts +++ b/projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.component.ts @@ -299,6 +299,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni this._pivotConfiguration = value; this.emitInitEvents(this._pivotConfiguration); this.filteringExpressionsTree = PivotUtil.buildExpressionTree(value); + this.setDateDimensionsLocaleData(); if (!this._init) { this.setupColumns(); } @@ -995,6 +996,7 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni this.setupColumns(); // Bind to onResourceChange after the columns have initialized the first time to avoid premature initialization. onResourceChangeHandle(this.destroy$, () => { + this.setDateDimensionsLocaleData(); // Since the columns are kinda static, due to assigning DisplayName on init, they need to be regenerated. this.setupColumns(); }, this); @@ -2487,6 +2489,35 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni protected trackHorizontalRowGroup = (_index: number, rowGroup: IPivotGridRecord[]) => rowGroup[0]?.dataIndex; + /** + * Sets the locale and resourceStrings data based on the grid's properties for all IgxPivotDateDimensions in the config. + */ + protected setDateDimensionsLocaleData() { + const topDimensions = [...this.columnDimensions, ...this.rowDimensions]; + for (const dim of topDimensions) { + let foundDateDim: IgxPivotDateDimension | undefined; + if (dim instanceof IgxPivotDateDimension) { + foundDateDim = dim; + } else if (dim.childLevel) { + var curChild: IPivotDimension | undefined = dim.childLevel; + while(curChild) { + if (curChild instanceof IgxPivotDateDimension) { + foundDateDim = curChild; + break; + } + curChild = curChild.childLevel; + } + } + + if (foundDateDim) { + foundDateDim.resourceStrings = this.resourceStrings; + if (this.locale) { + foundDateDim.locale = this.locale; + } + } + } + } + /** * @hidden @internal */