Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Comment thread
skrustev marked this conversation as resolved.
Comment thread
skrustev marked this conversation as resolved.
if (!this._init) {
this.setupColumns();
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
*/
Expand Down
Loading