Skip to content

Commit 4d01b26

Browse files
committed
fix(pivot-grid): fix the locale change
1 parent 37a8649 commit 4d01b26

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

projects/igniteui-angular/grids/core/src/pivot-grid-dimensions.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ export class IgxPivotDateDimension implements IPivotDimension {
107107
/** @hidden @internal */
108108
public memberName = 'AllPeriods';
109109
public displayName: string;
110+
/**
111+
* Gets/Sets the locale used for date dimension member formatting (e.g. month names).
112+
* When set, overrides the global I18nManager locale for this dimension.
113+
* Set automatically by the pivot grid row pipe when the grid locale changes.
114+
* @hidden @internal
115+
*/
116+
public locale: string;
110117
private _resourceStrings: IGridResourceStrings = null;
111118
private _baseDimension: IPivotDimension;
112119
private _options: IPivotDateDimensionOptions = {};
@@ -158,7 +165,7 @@ export class IgxPivotDateDimension implements IPivotDimension {
158165
const hasValue = value !== null && value !== undefined && value !== '';
159166
const dateValue = hasValue ? dateFormatter.createDateFromValue(value) : null;
160167
if (dateValue) {
161-
return dateFormatter.formatDateTime(dateValue, undefined, { dateStyle: 'short' });
168+
return dateFormatter.formatDateTime(dateValue, this.locale, { dateStyle: 'short' });
162169
}
163170
return hasValue ? String(value) : '';
164171
}
@@ -171,7 +178,7 @@ export class IgxPivotDateDimension implements IPivotDimension {
171178
memberFunction: (rec) => {
172179
const recordValue = PivotUtil.extractValueFromDimension(inBaseDimension, rec);
173180
const dateValue = (recordValue != null && recordValue !== '') ? getDateFormatter().createDateFromValue(recordValue) : null;
174-
return (recordValue != null && recordValue !== '') ? getDateFormatter().formatDateTime(dateValue, undefined, { month: 'long'}) : rec['Months'];
181+
return (recordValue != null && recordValue !== '') ? getDateFormatter().formatDateTime(dateValue, this.locale, { month: 'long'}) : rec['Months'];
175182
},
176183
enabled: true,
177184
childLevel: baseDimension

projects/igniteui-angular/grids/pivot-grid/src/pivot-grid.pipes.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
IPivotGridRecord,
1414
IPivotKeys,
1515
IPivotValue,
16+
IgxPivotDateDimension,
1617
PivotColumnDimensionsStrategy,
1718
PivotGridType,
1819
PivotRowDimensionsStrategy,
@@ -51,6 +52,14 @@ export class IgxPivotRowPipe implements PipeTransform {
5152
// nothing to group and aggregate by ...
5253
return [];
5354
}
55+
const locale = this.grid?.locale;
56+
if (locale) {
57+
for (const dim of enabledRows) {
58+
if (dim instanceof IgxPivotDateDimension) {
59+
dim.locale = locale;
60+
}
61+
}
62+
}
5463
const rowStrategy = config.rowStrategy || PivotRowDimensionsStrategy.instance();
5564
const data = cloneArray(collection, true);
5665
return rowStrategy.process(data, enabledRows, config.values, cloneStrategy, pivotKeys);

0 commit comments

Comments
 (0)