Skip to content

Commit 1df54da

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Refactor selection code a bit to match new structures.
1 parent 011e14f commit 1df54da

File tree

2 files changed

+7
-22
lines changed

2 files changed

+7
-22
lines changed

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

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,22 @@ const MINIMUM_COLUMN_WIDTH = 200;
3030
providers: [{ provide: IgxRowDirective, useExisting: forwardRef(() => IgxPivotRowComponent) }]
3131
})
3232
export class IgxPivotRowComponent extends IgxRowDirective {
33-
34-
@Input()
35-
public pivotRowWidths: number;
36-
public rowDimensionData: IPivotDimensionData[] = [];
37-
38-
public get rowDimension() {
39-
return this.rowDimensionData?.map(x => x.column);
40-
}
41-
4233
/**
4334
* @hidden
4435
*/
4536
@Input()
4637
@HostBinding('attr.aria-selected')
4738
public get selected(): boolean {
4839
let isSelected = false;
49-
this.rowDimensionData.forEach(x => {
50-
const key = this.getRowDimensionKey(x.column as IgxColumnComponent);
40+
let prevDims = [];
41+
for (let rowDim of this.grid.rowDimensions) {
42+
const dimData = PivotUtil.getDimensionLevel(rowDim, this.data, this.grid.pivotKeys);
43+
const key = PivotUtil.getRecordKey(this.data, dimData.dimension, prevDims, this.grid.pivotKeys);
5144
if (this.selectionService.isPivotRowSelected(key)) {
5245
isSelected = true;
5346
}
54-
});
47+
prevDims.push(dimData.dimension);
48+
}
5549
return isSelected;
5650
}
5751

@@ -73,16 +67,6 @@ export class IgxPivotRowComponent extends IgxRowDirective {
7367
return this.index;
7468
}
7569

76-
/**
77-
* @hidden
78-
* @internal
79-
*/
80-
public getRowDimensionKey(col: IgxColumnComponent) {
81-
const dimData = this.rowDimensionData.find(x => x.column.field === col.field);
82-
const key = PivotUtil.getRecordKey(this.data, dimData.dimension, dimData.prevDimensions, this.grid.pivotKeys);
83-
return key;
84-
}
85-
8670
public getCellClass(col: IgxColumnComponent) {
8771
const configuration = this.grid.pivotConfiguration;
8872
if (configuration.values.length === 1) {

src/app/pivot-grid/pivot-grid.sample.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
</div>
1414

1515
<igx-pivot-grid #grid1 [data]="origData" [width]="'100%'" [height]="'100%'" [defaultExpandState]='true'
16+
[rowSelection] = '"single"'
1617
[pivotConfiguration]="pivotConfigHierarchy" (dimensionsChange)='dimensionChange($event)'>
1718
</igx-pivot-grid>
1819

0 commit comments

Comments
 (0)