Skip to content

Commit 58d66fa

Browse files
authored
Merge pull request #7884 from IgniteUI/ddincheva/copyBugFixs
Fix: Copied data is not correct when grid paging is enabled
2 parents 6e4ec33 + 5392b6a commit 58d66fa

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5487,6 +5487,7 @@ export class IgxGridBaseDirective extends DisplayDensityBase implements
54875487
}
54885488

54895489
for (let [row, set] of selectionMap) {
5490+
row = this.paging ? row + (this.perPage * this.page) : row;
54905491
row = isRemote ? row - this.virtualizationState.startIndex : row;
54915492
if (!source[row] || source[row].detailsData !== undefined) {
54925493
continue;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@ describe('IgxGrid - Clipboard #grid', () => {
9090
expect(eventData).toEqual('Downloads\tReleased\r\n127\ttrue\r\n20\t\r\n');
9191
});
9292

93+
it('Copy data when paging is enabled', () => {
94+
grid.paging = true;
95+
grid.perPage = 5;
96+
fix.detectChanges();
97+
grid.page = 1;
98+
fix.detectChanges();
99+
const copySpy = spyOn<any>(grid.onGridCopy, 'emit').and.callThrough();
100+
grid.clipboardOptions.copyHeaders = false;
101+
grid.selectRange({ rowStart: 1, rowEnd: 2, columnStart: 2, columnEnd: 3 });
102+
fix.detectChanges();
103+
104+
const eventData = dispatchCopyEventOnGridBody(fix);
105+
expect(copySpy).toHaveBeenCalledTimes(1);
106+
expect(eventData).toEqual('0\ttrue\r\n1000\t\r\n');
107+
});
108+
93109
it('Disable clipboardOptions', () => {
94110
const copySpy = spyOn<any>(grid.onGridCopy, 'emit').and.callThrough();
95111
grid.clipboardOptions.enabled = false;

0 commit comments

Comments
 (0)