Skip to content

Commit c767ff8

Browse files
authored
Merge branch '7.3.x' into mkirova/fix-5683
2 parents d9ad49c + a2d05b9 commit c767ff8

File tree

7 files changed

+79
-5
lines changed

7 files changed

+79
-5
lines changed

projects/igniteui-angular/src/lib/directives/for-of/for_of.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
412412
if (changes) {
413413
// re-init cache.
414414
if (!this.igxForOf) {
415-
return;
415+
this.igxForOf = [];
416416
}
417417
this._updateSizeCache();
418418
this._zone.run(() => {
@@ -1453,7 +1453,7 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
14531453
this.onDataChanging.emit(args);
14541454
// re-init cache.
14551455
if (!this.igxForOf) {
1456-
return;
1456+
this.igxForOf = [];
14571457
}
14581458
/* we need to reset the master dir if all rows are removed
14591459
(e.g. because of filtering); if all columns are hidden, rows are

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ describe('IgxGrid Component Tests', () => {
145145
}
146146
});
147147

148+
it('should remove all rows if data becomes null/undefined.', async () => {
149+
const fix = TestBed.createComponent(IgxGridRemoteVirtualizationComponent);
150+
fix.detectChanges();
151+
const grid = fix.componentInstance.instance;
152+
expect(grid.rowList.length).toEqual(10);
153+
154+
fix.componentInstance.nullData();
155+
fix.detectChanges();
156+
157+
const noRecordsSpan = fix.debugElement.query(By.css('.igx-grid__tbody-message'));
158+
expect(grid.rowList.length).toEqual(0);
159+
expect(noRecordsSpan).toBeTruthy();
160+
expect(noRecordsSpan.nativeElement.innerText).toBe('Grid has no data.');
161+
});
162+
148163
it('height/width should be calculated depending on number of records', fakeAsync(() => {
149164
const fix = TestBed.createComponent(IgxGridTestComponent);
150165
fix.componentInstance.grid.height = null;
@@ -4424,6 +4439,10 @@ export class LocalService {
44244439
this.records = this._records.asObservable();
44254440
}
44264441

4442+
nullData() {
4443+
this._records.next(null);
4444+
}
4445+
44274446
public getData(data?: IForOfState, cb?: (any) => void): any {
44284447
const size = data.chunkSize === 0 ? 10 : data.chunkSize;
44294448
this.dataStore = this.generateData(data.startIndex, data.startIndex + size);
@@ -4461,6 +4480,10 @@ export class IgxGridRemoteVirtualizationComponent implements OnInit, AfterViewIn
44614480
this.data = this.localService.records;
44624481
}
44634482

4483+
nullData() {
4484+
this.localService.nullData();
4485+
}
4486+
44644487
public ngAfterViewInit() {
44654488
this.localService.getData(this.instance.virtualizationState, (count) => {
44664489
this.instance.totalItemCount = count;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ export abstract class IgxHierarchicalGridBaseComponent extends IgxGridBaseCompon
143143
const result = flatten(columns);
144144
this.columnList.reset(result);
145145
this.columnList.notifyOnChanges();
146+
this.initPinning();
146147
}
147148

148149
protected _createColumn(col) {

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,35 @@ describe('IgxHierarchicalGrid Integration', () => {
941941
expect(childGrid.columnList.toArray()[0].pinned).toBeTruthy();
942942
expect(headers[0].classList.contains('igx-grid__th--pinned')).toBeTruthy();
943943
}));
944+
945+
it('should be applied correctly for child grid with multi-column header.', (() => {
946+
const ri = fixture.componentInstance.rowIsland;
947+
const col = ri.columnList.find(x => x.header === 'Information');
948+
col.pinned = true;
949+
fixture.detectChanges();
950+
951+
const row = hierarchicalGrid.getRowByIndex(0) as IgxHierarchicalRowComponent;
952+
UIInteractions.clickElement(row.expander);
953+
fixture.detectChanges();
954+
955+
const childGrids = fixture.debugElement.queryAll(By.css('igx-child-grid-row'));
956+
const childGrid = childGrids[0].query(By.css('igx-hierarchical-grid')).componentInstance;
957+
// check unpinned/pinned columns
958+
expect(childGrid.pinnedColumns.length).toBe(3);
959+
expect(childGrid.unpinnedColumns.length).toBe(1);
960+
// check cells
961+
const cells = childGrid.getRowByIndex(0).cells;
962+
expect(cells.length).toBe(3);
963+
let cell = childGrid.getCellByColumn(0, 'ChildLevels');
964+
expect(cell.visibleColumnIndex).toEqual(0);
965+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(true);
966+
cell = childGrid.getCellByColumn(0, 'ProductName');
967+
expect(cell.visibleColumnIndex).toEqual(1);
968+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(true);
969+
cell = childGrid.getCellByColumn(0, 'ID');
970+
expect(cell.visibleColumnIndex).toEqual(2);
971+
expect(cell.nativeElement.classList.contains('igx-grid__td--pinned')).toBe(false);
972+
}));
944973
});
945974
});
946975

src/app/grid-remote-virtualization/grid-remote-virtualization.sample.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
</igx-grid>
44

55
<button (click)="loadData()">loadData</button>
6+
<button (click)="loadNullData()">null Data</button>
7+
<button (click)="loadUndefinedData()">undefined Data</button>
68
</div>

src/app/grid-remote-virtualization/grid-remote-virtualization.sample.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,24 @@ export class GridVirtualizationSampleComponent implements OnInit, AfterViewInit
4646

4747
public loadData() {
4848
this.grid.shouldGenerate = true;
49+
this.remoteService.getData(this.grid.virtualizationState, (data) => {
50+
this.remoteData = this.remoteService.remoteData;
51+
});
52+
}
53+
54+
public loadNullData() {
55+
this.remoteService.nullData();
56+
this.remoteData = this.remoteService.remoteData;
57+
}
58+
59+
public loadUndefinedData() {
60+
this.remoteService.undefinedData();
4961
this.remoteData = this.remoteService.remoteData;
5062
}
5163

5264
public ngAfterViewInit() {
53-
this.remoteService.getData(this.grid.virtualizationState, (data) => {
54-
this.grid.totalItemCount = data['@odata.count'];
55-
});
65+
this.remoteService.nullData();
66+
this.remoteData = this.remoteService.remoteData;
5667
}
5768

5869
dataLoading(evt) {

src/app/shared/remote.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export class RemoteService {
1616
this.remoteData = this._remoteData.asObservable();
1717
}
1818

19+
nullData() {
20+
this._remoteData.next(null);
21+
}
22+
23+
undefinedData() {
24+
this._remoteData.next(undefined);
25+
}
26+
1927
getData(data?: any, cb?: (any) => void) {
2028
const dataState = data;
2129
return this.http.get(this.buildUrl(dataState)).pipe(

0 commit comments

Comments
 (0)