Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(grid): set correct indexes of rows with selected data in the extractDataFromSelection method #10281

Merged
merged 3 commits into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6942,7 +6942,7 @@ export abstract class IgxGridBaseDirective extends DisplayDensityBase implements

// eslint-disable-next-line prefer-const
for (let [row, set] of selectionMap) {
row = this.paginator ? row + (this.paginator.perPage * this.paginator.page) : row;
row = this.paginator && source === this.filteredSortedData ? row + (this.paginator.perPage * this.paginator.page) : row;
row = isRemote ? row - this.virtualizationState.startIndex : row;
if (!source[row] || source[row].detailsData !== undefined) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testin
import { configureTestSuite } from '../../test-utils/configure-suite';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { By } from '@angular/platform-browser';
import { UIInteractions, wait, waitForActiveNodeChange} from '../../test-utils/ui-interactions.spec';
import { UIInteractions, wait, waitForActiveNodeChange } from '../../test-utils/ui-interactions.spec';
import { IgxGridModule } from './public_api';
import { IgxGridComponent } from './grid.component';
import { IgxGridRowComponent } from './grid-row.component';
Expand Down Expand Up @@ -42,7 +42,7 @@ describe('IgxGrid Master Detail #grid', () => {
}));

describe('Basic', () => {
beforeEach( fakeAsync(() => {
beforeEach(fakeAsync(() => {
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
fix.detectChanges();
grid = fix.componentInstance.grid;
Expand Down Expand Up @@ -689,7 +689,7 @@ describe('IgxGrid Master Detail #grid', () => {

describe('Integration', () => {
describe('Paging', () => {
it('Should not take into account expanded detail views as additional records.', fakeAsync(() => {
it('Should not take into account expanded detail views as additional records.', fakeAsync(() => {
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
grid = fix.componentInstance.grid;
fix.detectChanges();
Expand Down Expand Up @@ -859,6 +859,48 @@ describe('IgxGrid Master Detail #grid', () => {
fix.detectChanges();
expect(grid.getSelectedData()).toEqual(expectedData);
}));

it('getSelectedData should return correct values when there are master details and paging is enabled', fakeAsync(() => {
const range = { rowStart: 0, rowEnd: 5, columnStart: 'ContactName', columnEnd: 'ContactName' };
const expectedDataFromSecondPage = [
{ ContactName: 'Hanna Moos' },
{ ContactName: 'Frédérique Citeaux' },
{ ContactName: 'Martín Sommer' }
];
fix.componentInstance.paging = true;
fix.detectChanges();
grid.paginator.perPage = 5;
fix.detectChanges();
tick(16);
grid.paginator.paginate(1);
fix.detectChanges();
tick(16);

grid.expandAll();
tick(100);
fix.detectChanges();

grid.selectRange(range);
fix.detectChanges();
expect(grid.getSelectedData()).toEqual(expectedDataFromSecondPage);

const expectedDataFromThirdPage = [
{ ContactName: 'Victoria Ashworth' },
{ ContactName: 'Patricio Simpson' },
{ ContactName: 'Francisco Chang' }
];
grid.paginator.paginate(2);
fix.detectChanges();
tick(16);

grid.expandAll();
tick(100);
fix.detectChanges();

grid.selectRange(range);
fix.detectChanges();
expect(grid.getSelectedData()).toEqual(expectedDataFromThirdPage);
}));
});

describe('Row Selection', () => {
Expand Down