Skip to content

Commit 6aeecbd

Browse files
committed
chore(*): Add more accurate check if a row is selected
1 parent 778bfd1 commit 6aeecbd

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed

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

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,19 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
411411
this.dataView.forEach(record => {
412412
const prev = [];
413413
for (const dim of this.rowDimensions) {
414-
const currDim = record[dim.memberName] ? dim : record[dim.childLevel.memberName] ? dim.childLevel : dim;
415-
const key = PivotUtil.getRecordKey(record, currDim, prev);
416-
prev.push(currDim);
417-
if (this.selectionService.isPivotRowSelected(key) && !selectedRowIds.find(x => x === record)) {
418-
selectedRowIds.push(record);
414+
let currDim = dim;
415+
let shouldBreak = false;
416+
do {
417+
const key = PivotUtil.getRecordKey(record, currDim, prev);
418+
if (this.selectionService.isPivotRowSelected(key) && !selectedRowIds.find(x => x === record)) {
419+
selectedRowIds.push(record);
420+
shouldBreak = true;
421+
break;
422+
}
423+
currDim = currDim.childLevel;
424+
} while (currDim);
425+
prev.push(dim);
426+
if (shouldBreak) {
419427
break;
420428
}
421429
}
@@ -449,29 +457,29 @@ export class IgxPivotGridComponent extends IgxGridBaseDirective implements OnIni
449457
@Inject(LOCALE_ID) localeId: string,
450458
protected platform: PlatformUtil,
451459
@Optional() @Inject(IgxGridTransaction) protected _diTransactions?: TransactionService<Transaction, State>) {
452-
super(
453-
selectionService,
454-
colResizingService,
455-
gridAPI,
456-
transactionFactory,
457-
elementRef,
458-
zone,
459-
document,
460-
cdr,
461-
resolver,
462-
differs,
463-
viewRef,
464-
appRef,
465-
moduleRef,
466-
factoryResolver,
467-
injector,
468-
navigation,
469-
filteringService,
470-
overlayService,
471-
summaryService,
472-
_displayDensityOptions,
473-
localeId,
474-
platform);
460+
super(
461+
selectionService,
462+
colResizingService,
463+
gridAPI,
464+
transactionFactory,
465+
elementRef,
466+
zone,
467+
document,
468+
cdr,
469+
resolver,
470+
differs,
471+
viewRef,
472+
appRef,
473+
moduleRef,
474+
factoryResolver,
475+
injector,
476+
navigation,
477+
filteringService,
478+
overlayService,
479+
summaryService,
480+
_displayDensityOptions,
481+
localeId,
482+
platform);
475483
}
476484

477485
/**

projects/igniteui-angular/src/lib/grids/selection/selection.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ export class IgxGridSelectionService {
494494
public isPivotRowSelected(rowID): boolean {
495495
let contains = false;
496496
this.rowSelection.forEach(x => {
497-
if (rowID.includes(x)) {
497+
const correctRowId = rowID.replace(x,'');
498+
if (rowID.includes(x) && (correctRowId === '' || correctRowId.startsWith('_')) ) {
498499
contains = true;
499500
return;
500501
}

0 commit comments

Comments
 (0)