Skip to content

Commit 15c9ef5

Browse files
authored
fix(hgrid-copy): correctly calculate expanded rows (#12474)
* fix(hgrid-copy): correctly calculate expanded rows * fix(hgrid-copy): handle selection 'none' case
1 parent dce3248 commit 15c9ef5

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

projects/igniteui-angular/src/lib/grids/grid-base.directive.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7235,35 +7235,32 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements
72357235
const expansionRowIndexes = [];
72367236
for (const [key, value] of this.expansionStates.entries()) {
72377237
if (value) {
7238-
expansionRowIndexes.push(key);
7238+
const rowIndex = this.gridAPI.get_rec_index_by_id(key, this.dataView);
7239+
expansionRowIndexes.push(rowIndex);
72397240
}
72407241
}
72417242
if (this.selectionService.selection.size > 0) {
72427243
if (expansionRowIndexes.length > 0) {
72437244
for (const [key, value] of this.selectionService.selection.entries()) {
72447245
let updatedKey = key;
7245-
expansionRowIndexes.forEach(row => {
7246-
let rowIndex;
7247-
if (!isNaN(row.ID)) {
7248-
rowIndex = Number(row.ID);
7249-
} else {
7250-
rowIndex = Number(row);
7251-
}
7252-
7253-
if (updatedKey > Number(rowIndex)) {
7254-
updatedKey--;
7246+
let subtract = 0;
7247+
expansionRowIndexes.forEach((row) => {
7248+
if (updatedKey > Number(row)) {
7249+
subtract++;
72557250
}
72567251
});
7257-
selectionCollection.set(updatedKey, value);
7252+
selectionCollection.set(updatedKey - subtract, value);
72587253
}
72597254
}
72607255
} else if (activeEl) {
7256+
let subtract = 0;
72617257
if (expansionRowIndexes.length > 0) {
72627258
expansionRowIndexes.forEach(row => {
72637259
if (activeEl.row > Number(row)) {
7264-
activeEl.row--;
7260+
subtract++;
72657261
}
72667262
});
7263+
activeEl.row -= subtract;
72677264
}
72687265
}
72697266
}

0 commit comments

Comments
 (0)