Skip to content

Commit a521fbf

Browse files
authored
Merge branch '8.1.x' into validate-comments-8.1.x
2 parents 8ba053b + e561522 commit a521fbf

File tree

11 files changed

+100
-12
lines changed

11 files changed

+100
-12
lines changed

projects/igniteui-angular/src/lib/core/styles/components/grid/_excel-filtering-theme.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
/// @requires --var
1313
@mixin _excel-filtering($theme, $palette) {
1414
%grid-excel-filter {
15-
height: rem(15px);
1615
display: block;
1716
}
1817

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,19 @@ describe('IgxForOf directive -', () => {
255255
}
256256
});
257257

258+
it('should not throw error when itemSize is changed while data is null/undefined.', () => {
259+
let errorMessage = '';
260+
fix.componentInstance.data = null;
261+
fix.detectChanges();
262+
try {
263+
fix.componentInstance.itemSize = '100px';
264+
fix.detectChanges();
265+
} catch (ex) {
266+
errorMessage = ex.message;
267+
}
268+
expect(errorMessage).toBe('');
269+
});
270+
258271
it('should allow initially undefined value for igxForOf and then detect changes correctly once the value is updated', async () => {
259272
fix = TestBed.createComponent(VerticalVirtualNoDataComponent);
260273
expect(() => {

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
423423
}
424424
}
425425
const defaultItemSize = 'igxForItemSize';
426-
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && this.igxForScrollOrientation === 'vertical') {
426+
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange &&
427+
this.igxForScrollOrientation === 'vertical' && this.igxForOf) {
427428
// handle default item size changed.
428429
this.initSizesCache(this.igxForOf);
429430
this._applyChanges();
@@ -443,7 +444,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
443444
if (changes) {
444445
// re-init cache.
445446
if (!this.igxForOf) {
446-
return;
447+
this.igxForOf = [];
447448
}
448449
this._updateSizeCache();
449450
this._zone.run(() => {
@@ -1325,7 +1326,8 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
13251326
}
13261327
}
13271328
const defaultItemSize = 'igxForItemSize';
1328-
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange && this.igxForScrollOrientation === 'vertical') {
1329+
if (defaultItemSize in changes && !changes[defaultItemSize].firstChange &&
1330+
this.igxForScrollOrientation === 'vertical' && this.igxForOf) {
13291331
// handle default item size changed.
13301332
this.initSizesCache(this.igxForOf);
13311333
}
@@ -1486,7 +1488,7 @@ export class IgxGridForOfDirective<T> extends IgxForOfDirective<T> implements On
14861488
this.onDataChanging.emit(args);
14871489
// re-init cache.
14881490
if (!this.igxForOf) {
1489-
return;
1491+
this.igxForOf = [];
14901492
}
14911493
/* we need to reset the master dir if all rows are removed
14921494
(e.g. because of filtering); if all columns are hidden, rows are

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {
1414
import {
1515
HorizontalAlignment,
1616
VerticalAlignment,
17-
ConnectedPositioningStrategy,
1817
OverlaySettings,
1918
IgxOverlayService,
20-
AbsoluteScrollStrategy
19+
AbsoluteScrollStrategy,
20+
AutoPositionStrategy
2121
} from '../../../services/index';
2222
import { IgxFilteringService, ExpressionUI } from '../grid-filtering.service';
2323
import { IgxToggleDirective } from '../../../directives/toggle/toggle.directive';
@@ -115,7 +115,7 @@ export class IgxGridExcelStyleFilteringComponent implements OnDestroy, OnInit, A
115115
private _subMenuOverlaySettings: OverlaySettings = {
116116
closeOnOutsideClick: true,
117117
modal: false,
118-
positionStrategy: new ConnectedPositioningStrategy(this._subMenuPositionSettings),
118+
positionStrategy: new AutoPositionStrategy(this._subMenuPositionSettings),
119119
scrollStrategy: new AbsoluteScrollStrategy()
120120
};
121121

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
@@ -150,6 +150,21 @@ describe('IgxGrid Component Tests', () => {
150150
}
151151
});
152152

153+
it('should remove all rows if data becomes null/undefined.', async () => {
154+
const fix = TestBed.createComponent(IgxGridRemoteVirtualizationComponent);
155+
fix.detectChanges();
156+
const grid = fix.componentInstance.instance;
157+
expect(grid.rowList.length).toEqual(10);
158+
159+
fix.componentInstance.nullData();
160+
fix.detectChanges();
161+
162+
const noRecordsSpan = fix.debugElement.query(By.css('.igx-grid__tbody-message'));
163+
expect(grid.rowList.length).toEqual(0);
164+
expect(noRecordsSpan).toBeTruthy();
165+
expect(noRecordsSpan.nativeElement.innerText).toBe('Grid has no data.');
166+
});
167+
153168
it('height/width should be calculated depending on number of records', fakeAsync(() => {
154169
const fix = TestBed.createComponent(IgxGridTestComponent);
155170
fix.componentInstance.grid.height = null;
@@ -4724,6 +4739,10 @@ export class LocalService {
47244739
this.records = this._records.asObservable();
47254740
}
47264741

4742+
nullData() {
4743+
this._records.next(null);
4744+
}
4745+
47274746
public getData(data?: IForOfState, cb?: (any) => void): any {
47284747
const size = data.chunkSize === 0 ? 10 : data.chunkSize;
47294748
this.dataStore = this.generateData(data.startIndex, data.startIndex + size);
@@ -4761,6 +4780,10 @@ export class IgxGridRemoteVirtualizationComponent implements OnInit, AfterViewIn
47614780
this.data = this.localService.records;
47624781
}
47634782

4783+
nullData() {
4784+
this.localService.nullData();
4785+
}
4786+
47644787
public ngAfterViewInit() {
47654788
this.localService.getData(this.instance.virtualizationState, (count) => {
47664789
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
@@ -163,6 +163,7 @@ export abstract class IgxHierarchicalGridBaseComponent extends IgxGridBaseCompon
163163
const result = flatten(columns);
164164
this.columnList.reset(result);
165165
this.columnList.notifyOnChanges();
166+
this.initPinning();
166167
}
167168

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

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/hierarchical-grid-remote/hierarchical-grid-remote.sample.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<button (click)='setterBindingChange()'>Set rowSelectable via binding</button>
22
<button (click)='setterChange()'>Set rowSelectable via setter on 1st row island</button>
3-
<igx-hierarchical-grid #grid1 [data]="remoteData" [primaryKey]="'CustomerID'" [autoGenerate]="false" [height]="'800px'" [width]="'100%'" #hGrid [emptyGridMessage]="''">
3+
<igx-hierarchical-grid #grid1 displayDensity="cosy" [data]="remoteData" [primaryKey]="'CustomerID'" [autoGenerate]="false" [height]="'800px'" [width]="'100%'" #hGrid [emptyGridMessage]="''">
44
<igx-column field="CustomerID"></igx-column>
55
<igx-column field="CompanyName"></igx-column>
66
<igx-column field="ContactName"></igx-column>

0 commit comments

Comments
 (0)