Skip to content

Commit 21c1a99

Browse files
authored
Merge branch '19.2.x' into bpachilova/fix-unpinned-col-position-15542-19.2.x
2 parents 5437ab8 + 72df18a commit 21c1a99

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6738,7 +6738,7 @@ export abstract class IgxGridBaseDirective implements GridType,
67386738
}
67396739

67406740
protected getColumnList() {
6741-
return this.columnList.toArray();
6741+
return this.columnList.toArray().filter((col) => col.grid === this);
67426742
}
67436743

67446744
/**
@@ -6796,6 +6796,9 @@ export abstract class IgxGridBaseDirective implements GridType,
67966796
let removed = false;
67976797
let pinning = false;
67986798
diff.forEachAddedItem((record: IterableChangeRecord<IgxColumnComponent>) => {
6799+
if (record.item.grid !== this) {
6800+
return;
6801+
}
67996802
added = true;
68006803
if (record.item.pinned) {
68016804
this._pinnedColumns.push(record.item);
@@ -6805,12 +6808,15 @@ export abstract class IgxGridBaseDirective implements GridType,
68056808
}
68066809
});
68076810

6808-
this.initColumns(this.columnList.toArray(), (col: IgxColumnComponent) => this.columnInit.emit(col));
6811+
this.initColumns(this.getColumnList(), (col: IgxColumnComponent) => this.columnInit.emit(col));
68096812
if (pinning) {
68106813
this.initPinning();
68116814
}
68126815

68136816
diff.forEachRemovedItem((record: IterableChangeRecord<IgxColumnComponent | IgxColumnGroupComponent>) => {
6817+
if (record.item.grid !== this) {
6818+
return;
6819+
}
68146820
const isColumnGroup = record.item instanceof IgxColumnGroupComponent;
68156821
if (!isColumnGroup) {
68166822
// Clear Grouping

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ViewChild, OnInit, DebugElement, QueryList, TemplateRef } from '@angular/core';
1+
import { Component, ViewChild, OnInit, DebugElement, QueryList, TemplateRef, ContentChild, ViewChildren } from '@angular/core';
22
import { TestBed, ComponentFixture, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
33
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
44
import { By } from '@angular/platform-browser';
@@ -358,6 +358,16 @@ describe('IgxGrid Master Detail #grid', () => {
358358
const firstDetail = GridFunctions.getMasterRowDetail(gridRows[0]);
359359
expect(firstDetail.textContent.trim()).toBe('NEW TEMPLATE');
360360
});
361+
362+
it('should allow grids in details view without breaking the column collection of the master grid', () => {
363+
grid = fix.componentInstance.grid;
364+
grid.detailTemplate = fix.componentInstance.gridTemplate;
365+
fix.detectChanges();
366+
grid.toggleRow(fix.componentInstance.data[0].ID);
367+
fix.detectChanges();
368+
expect(grid.unpinnedColumns.map(c => c.field)).toEqual(['ContactName', 'CompanyName']);
369+
expect(fix.componentInstance.childGrid.first.unpinnedColumns.map(c => c.field)).toEqual(['ColA', 'ColB']);
370+
});
361371
});
362372

363373
describe('Keyboard Navigation ', () => {
@@ -1282,6 +1292,12 @@ describe('IgxGrid Master Detail #grid', () => {
12821292
NEW TEMPLATE
12831293
</div>
12841294
</ng-template>
1295+
<ng-template igxGridDetail #gridTemplate>
1296+
<igx-grid #childGrid>
1297+
<igx-column [field]="'ColA'" [width]="'400px'"></igx-column>
1298+
<igx-column [field]="'ColB'" [width]="'400px'"></igx-column>
1299+
</igx-grid>
1300+
</ng-template>
12851301
`,
12861302
imports: [IgxGridComponent, IgxColumnComponent, IgxGridDetailTemplateDirective, IgxCheckboxComponent, IgxPaginatorComponent, IgxInputGroupComponent, IgxInputDirective]
12871303
})
@@ -1292,6 +1308,12 @@ export class DefaultGridMasterDetailComponent {
12921308
@ViewChild('detailTemplate', { read: TemplateRef, static: true })
12931309
public detailTemplate: TemplateRef<any>;
12941310

1311+
@ViewChild('gridTemplate', { read: TemplateRef, static: true })
1312+
public gridTemplate: TemplateRef<any>;
1313+
1314+
@ViewChildren('childGrid', { read: IgxGridComponent })
1315+
public childGrid: IgxGridComponent;
1316+
12951317
public width = '800px';
12961318
public height = '500px';
12971319
public data = SampleTestData.contactInfoDataFull();

0 commit comments

Comments
 (0)