Skip to content

Commit 906ac1f

Browse files
authored
Merge pull request #16012 from IgniteUI/skrastev/fix-15147-20.0.x
fix(pivotGrid): Column formatter argument not pupulated correctly.
2 parents c651342 + 07c75c8 commit 906ac1f

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-grid.spec.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,54 @@ describe('IgxPivotGrid #pivotGrid', () => {
22222222
GridSelectionFunctions.verifyColumnSelected(amountOfSale, false);
22232223
GridSelectionFunctions.verifyColumnGroupSelected(fixture, group, false);
22242224
});
2225+
2226+
it('should provide value formatter column data for second value', () => {
2227+
let correctFirstColumnData = true;
2228+
let correctSecondColumnData = true;
2229+
const pivotGrid = fixture.componentInstance.pivotGrid;
2230+
pivotGrid.pivotConfiguration = {
2231+
columns: fixture.componentInstance.pivotConfigHierarchy.columns,
2232+
rows: fixture.componentInstance.pivotConfigHierarchy.rows,
2233+
values: [
2234+
{
2235+
member: 'UnitsSold',
2236+
aggregate: {
2237+
aggregator: IgxPivotNumericAggregate.sum,
2238+
key: 'SUM',
2239+
label: 'Sum'
2240+
},
2241+
enabled: true,
2242+
formatter: (value, row, column) => {
2243+
if (!column || !column.value || column.value.member !== 'UnitsSold') {
2244+
correctFirstColumnData = false;
2245+
}
2246+
return value;
2247+
}
2248+
},
2249+
{
2250+
member: 'AmountOfSale',
2251+
displayName: 'Amount of Sale',
2252+
aggregate: {
2253+
aggregator: IgxTotalSaleAggregate.totalSale,
2254+
key: 'TOTAL',
2255+
label: 'Total'
2256+
},
2257+
enabled: true,
2258+
formatter: (value, row, column) => {
2259+
if (!column || !column.value || column.value.member !== 'AmountOfSale') {
2260+
correctSecondColumnData = false;
2261+
}
2262+
return value;
2263+
}
2264+
}
2265+
]
2266+
};
2267+
2268+
pivotGrid.width = '1500px';
2269+
fixture.detectChanges();
2270+
expect(correctFirstColumnData).toBeTruthy();
2271+
expect(correctSecondColumnData).toBeTruthy();
2272+
});
22252273
});
22262274

22272275
describe('IgxPivotGrid Resizing #pivotGrid', () => {

projects/igniteui-angular/src/lib/grids/pivot-grid/pivot-row.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ export class IgxPivotRowComponent extends IgxRowDirective {
189189
keyValueMap.set(dim.memberName, path.shift());
190190
}
191191
let pivotValue;
192-
if (this.grid.hasMultipleValues) {
193-
pivotValue = this.grid.values.find(x => x.member === path.shift());
192+
if (this.grid.hasMultipleValues && path.length) {
193+
pivotValue = this.grid.values.find(x => x.member === path[0]);
194194
} else {
195195
pivotValue = this.grid.values ? this.grid.values[0] : undefined;
196196
}

0 commit comments

Comments
 (0)