Skip to content

Commit 8f4a758

Browse files
authored
Merge branch '9.0.x' into mvenkov/input-with-null-value-9.0
2 parents 00ca426 + ad5ffaf commit 8f4a758

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,11 +1100,11 @@ export class IgxGridComponent extends IgxGridBaseDirective implements GridType,
11001100
* @inheritdoc
11011101
*/
11021102
getSelectedData(formatters = false, headers = false): any[] {
1103-
if (this.groupingExpressions.length) {
1103+
if (this.groupingExpressions.length || this.hasDetails) {
11041104
const source = [];
11051105

11061106
const process = (record) => {
1107-
if (record.expression || record.summaries) {
1107+
if (record.expression || record.summaries || this.isDetailRecord(record)) {
11081108
source.push(null);
11091109
return;
11101110
}

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

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, ViewChild, OnInit } from '@angular/core';
2-
import { async, TestBed, ComponentFixture } from '@angular/core/testing';
2+
import { async, TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
33
import { configureTestSuite } from '../../test-utils/configure-suite';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { By } from '@angular/platform-browser';
@@ -799,10 +799,13 @@ describe('IgxGrid Master Detail #grid', () => {
799799
});
800800

801801
describe('Cell Selection', () => {
802-
it('Should exclude expanded detail views when doing range cell selection', () => {
802+
beforeEach(fakeAsync(() => {
803803
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
804804
grid = fix.componentInstance.grid;
805805
fix.detectChanges();
806+
}));
807+
808+
it('Should exclude expanded detail views when doing range cell selection', fakeAsync(() => {
806809
grid.expandRow(fix.componentInstance.data[2].ID);
807810
const selectionChangeSpy = spyOn<any>(grid.onRangeSelection, 'emit').and.callThrough();
808811
const startCell = grid.getCellByColumn(1, 'ContactName');
@@ -837,7 +840,23 @@ describe('IgxGrid Master Detail #grid', () => {
837840
expect(selectionChangeSpy).toHaveBeenCalledTimes(1);
838841
expect(selectionChangeSpy).toHaveBeenCalledWith(range);
839842
expect(rowDetail.querySelector('[class*="selected"]')).toBeNull();
840-
});
843+
}));
844+
845+
it('getSelectedData should return correct values when there are master details', fakeAsync(() => {
846+
const range = { rowStart: 0, rowEnd: 5, columnStart: 'ContactName', columnEnd: 'ContactName' };
847+
const expectedData = [
848+
{ ContactName: 'Maria Anders' },
849+
{ ContactName: 'Ana Trujillo' },
850+
{ ContactName: 'Antonio Moreno' }
851+
];
852+
grid.expandAll();
853+
tick(100);
854+
fix.detectChanges();
855+
856+
grid.selectRange(range);
857+
fix.detectChanges();
858+
expect(grid.getSelectedData()).toEqual(expectedData);
859+
}));
841860
});
842861

843862
describe('Row Selection', () => {
@@ -1070,10 +1089,12 @@ describe('IgxGrid Master Detail #grid', () => {
10701089
describe('GroupBy', () => {
10711090
beforeEach(async() => {
10721091
fix = TestBed.createComponent(DefaultGridMasterDetailComponent);
1073-
fix.componentInstance.columns[0].hasSummary = true;
10741092
fix.detectChanges();
10751093

10761094
grid = fix.componentInstance.grid;
1095+
grid.getColumnByName('ContactName').hasSummary = true;
1096+
fix.detectChanges();
1097+
10771098
grid.summaryCalculationMode = GridSummaryCalculationMode.childLevelsOnly;
10781099
grid.groupingExpressions =
10791100
[{ fieldName: 'CompanyName', dir: SortingDirection.Asc, ignoreCase: false }];
@@ -1162,9 +1183,7 @@ describe('IgxGrid Master Detail #grid', () => {
11621183
template: `
11631184
<igx-grid [data]="data" [width]="width" [height]="height" [primaryKey]="'ID'" [allowFiltering]='true'
11641185
[paging]="paging" [perPage]="perPage" [rowSelectable]="rowSelectable">
1165-
<igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'
1166-
[hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable"
1167-
[hasSummary]="c.hasSummary" [pinned]='c.pinned'>
1186+
<igx-column *ngFor="let c of columns" [field]="c.field" [width]="c.width" [dataType]='c.dataType'>
11681187
</igx-column>
11691188
11701189
<ng-template igxGridDetail let-dataItem>
@@ -1203,9 +1222,7 @@ export class DefaultGridMasterDetailComponent {
12031222
template: `
12041223
<igx-grid [data]="data" [expansionStates]='expStates'
12051224
[width]="width" [height]="height" [primaryKey]="'ID'" [paging]="paging" [rowSelectable]="rowSelectable">
1206-
<igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'
1207-
[hidden]='c.hidden' [sortable]="c.sortable" [movable]='c.movable' [groupable]='c.groupable' [editable]="c.editable"
1208-
[hasSummary]="c.hasSummary" [pinned]='c.pinned'>
1225+
<igx-column *ngFor="let c of columns" [field]="c.field" [header]="c.field" [width]="c.width" [dataType]='c.dataType'>
12091226
</igx-column>
12101227
12111228
<ng-template igxGridDetail let-dataItem>

0 commit comments

Comments
 (0)