Skip to content

Commit 92ecff3

Browse files
committed
feat(pivot): add aditional logic to extract the correct selected row ids
1 parent 79a69e7 commit 92ecff3

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

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

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
236236
public pivotKeys: IPivotKeys = { aggregations: 'aggregations', records: 'records', children: 'children', level: 'level' };
237237
public isPivot = true;
238238

239+
/**
240+
* @hidden @internal
241+
*/
242+
public selectedPivotKeys = new Map<string, any[]>();
243+
239244
/**
240245
* @hidden @internal
241246
*/
@@ -371,6 +376,16 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
371376
public set batchEditing(_val: boolean) {
372377
}
373378

379+
public get selectedRows(): any[] {
380+
const selectedRowKeys = this.selectionService.getSelectedRows();
381+
const selectedRowIds = [];
382+
this.selectedPivotKeys.forEach((value, key) => {
383+
if (selectedRowKeys.find(x => key.includes(x)) && !selectedRowIds.find(x => x === value)) {
384+
selectedRowIds.push(value);
385+
}
386+
});
387+
return selectedRowIds;
388+
}
374389
/**
375390
* @hidden
376391
*/
@@ -799,10 +814,10 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
799814
fieldsMap = this.generateFromData(filteredFields);
800815
} else {
801816
fieldsMap = PivotUtil.getFieldsHierarchy(
802-
data,
803-
this.columnDimensions,
804-
PivotDimensionType.Column,
805-
{aggregations: 'aggregations', records: 'records', children: 'children', level: 'level'}
817+
data,
818+
this.columnDimensions,
819+
PivotDimensionType.Column,
820+
{ aggregations: 'aggregations', records: 'records', children: 'children', level: 'level' }
806821
);
807822
}
808823
columns = this.generateColumnHierarchy(fieldsMap, data);

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,15 @@ export class IgxPivotRowComponent extends IgxRowDirective<IgxPivotGridComponent>
6262
public get selected(): boolean {
6363
let isSelected = false;
6464
this.rowDimensionData.forEach(x => {
65-
if (this.selectionService.isPivotRowSelected(this.getRowDimensionKey(x.column))) {
65+
const key = this.getRowDimensionKey(x.column);
66+
if (this.selectionService.isPivotRowSelected(key)) {
6667
isSelected = true;
68+
if (!this.grid.selectedPivotKeys.get(key)) {
69+
this.grid.selectedPivotKeys.set(key, this.rowData);
70+
}
71+
}
72+
else {
73+
this.grid.selectedPivotKeys.delete(key);
6774
}
6875
});
6976
return isSelected;

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<div class="sample-column">
2-
<button igxButton (click)="test()">TEST</button>
32
<igx-pivot-grid #grid1 [data]="origData" [width]="'100%'" [height]="'100%'" [pivotConfiguration]="pivotConfigHierarchy"
43
[rowSelection]="'single'"
54
[columnSelection]="'single'"

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

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,4 @@ export class PivotGridSampleComponent {
105105
ProductCategory: 'Components', UnitPrice: 16.05, SellerName: 'Walter Pang',
106106
Country: 'Bulgaria', City: 'Sofia', Date: '02/19/2013', UnitsSold: 492
107107
}];
108-
109-
public test() {
110-
console.log(this.grid1.selectedColumns());
111-
}
112108
}

0 commit comments

Comments
 (0)