Skip to content

Commit bb82916

Browse files
authored
Merge branch '7.2.x' into mkirova/fix-5102
2 parents 1afa448 + 3a40e25 commit bb82916

File tree

7 files changed

+57
-19
lines changed

7 files changed

+57
-19
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ export class IgxForOfDirective<T> implements OnInit, OnChanges, DoCheck, OnDestr
12171217

12181218
private _getItemSize(item, dimension: string): number {
12191219
const dim = item[dimension];
1220-
return typeof dim === 'number' ? dim : this.igxForItemSize;
1220+
return typeof dim === 'number' ? dim : parseInt(this.igxForItemSize, 10) || 0;
12211221
}
12221222
}
12231223

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,43 @@ describe('IgxTreeGrid - CRUD', () => {
293293
verifyTreeGridRecordsCount(fix, 3, 8);
294294
verifyProcessedTreeGridRecordsCount(fix, 3, 8);
295295
});
296+
297+
it('should support adding child rows to a parent with ID=0 through treeGrid API', () => {
298+
verifyRowsCount(fix, 8, 8);
299+
verifyTreeGridRecordsCount(fix, 3, 8);
300+
verifyProcessedTreeGridRecordsCount(fix, 3, 8);
301+
302+
// Add child row with ID=0 on root level
303+
spyOn(treeGrid.onRowAdded, 'emit');
304+
let newRow = {
305+
ID: 0,
306+
Name: 'New Employee 1',
307+
JobTitle: 'Senior Web Developer',
308+
Age: 33
309+
};
310+
treeGrid.addRow(newRow);
311+
fix.detectChanges();
312+
313+
expect(treeGrid.onRowAdded.emit).toHaveBeenCalledWith({ data: newRow });
314+
verifyRowsCount(fix, 9, 9);
315+
verifyTreeGridRecordsCount(fix, 4, 9);
316+
verifyProcessedTreeGridRecordsCount(fix, 4, 9);
317+
318+
// Add child row to the parent with ID=0
319+
newRow = {
320+
ID: 333,
321+
Name: 'New Employee 2',
322+
JobTitle: 'Senior Web Developer',
323+
Age: 33
324+
};
325+
treeGrid.addRow(newRow, 0);
326+
fix.detectChanges();
327+
328+
expect(treeGrid.onRowAdded.emit).toHaveBeenCalledWith({ data: newRow });
329+
verifyRowsCount(fix, 10, 10);
330+
verifyTreeGridRecordsCount(fix, 4, 10);
331+
verifyProcessedTreeGridRecordsCount(fix, 4, 10);
332+
});
296333
});
297334
});
298335

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ describe('IgxTreeGrid - Integration', () => {
849849
const grandChildRow = { ID: 13, ParentID: 12, Name: 'Asparuh Pulev', JobTitle: 'wrestler', Age: 14 };
850850
const trans = treeGrid.transactions;
851851

852-
treeGrid.addRow(rootRow, 0);
852+
treeGrid.addRow(rootRow);
853853
fix.detectChanges();
854854

855855
treeGrid.addRow(childRow, 11);
@@ -924,7 +924,7 @@ describe('IgxTreeGrid - Integration', () => {
924924
JobTitle: 'Copywriter',
925925
Age: 22
926926
};
927-
treeGrid.addRow(newRow, 0);
927+
treeGrid.addRow(newRow);
928928
fix.detectChanges();
929929

930930
const addedRow = treeGrid.rowList.filter(r => r.rowID === addedRowId)[0] as IgxTreeGridRowComponent;
@@ -1322,7 +1322,7 @@ describe('IgxTreeGrid - Integration', () => {
13221322
const grandChildRow = { ID: 13, ParentID: 12, Name: 'Asparuh Pulev', JobTitle: 'wrestler', Age: 14 };
13231323
const trans = treeGrid.transactions;
13241324

1325-
treeGrid.addRow(rootRow, 0);
1325+
treeGrid.addRow(rootRow);
13261326
fix.detectChanges();
13271327

13281328
treeGrid.addRow(childRow, 11);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ export class IgxTreeGridComponent extends IgxGridBaseComponent implements IGridD
415415
* @memberof IgxTreeGridComponent
416416
*/
417417
public addRow(data: any, parentRowID?: any) {
418-
if (parentRowID) {
418+
if (parentRowID !== undefined && parentRowID !== null) {
419419
const parentRecord = this.records.get(parentRowID);
420420

421421
if (!parentRecord) {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.overflowContainer > .igx-display-container {
2+
overflow: visible !important;
3+
}
4+
.overflowContainer {
5+
position: relative;
6+
overflow: hidden;
7+
}

src/app/virtual-for-directive/virtual-for.sample.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@
2424
<table>
2525
<tbody style='display:grid;'>
2626
<tr style='width:500px; height:100px;'>
27-
<div style='position: relative; overflow: hidden'>
27+
<div class='overflowContainer'>
2828
<ng-template igxFor let-item [igxForOf]="data" #virtDirHorizontal
2929
[igxForScrollOrientation]="'horizontal'"
3030
[igxForContainerSize]='"500px"'
31+
[igxForItemSize]='"200px"'
3132
let-rowIndex="index">
32-
<td [style.width.px]='item.width' [style.min-width.px]='item.width' style='height:100px;'>{{rowIndex}} : {{item.text}}</td>
33+
<td [style.width.px]='200' [style.min-width.px]='200' style='height:100px;'>{{rowIndex}} : {{item.text}}</td>
3334
</ng-template>
3435
</div>
3536
</tr>
3637
</tbody>
3738
</table>
39+
<br/>
3840
<button (click)="scrNextCol()">Scroll Next Column</button>
3941
<button (click)="scrPrevCol()">Scroll Prev Column</button>
4042
<button (click)="scrNextHorizontalPage()">Scroll Next Horizontal Page</button>

src/app/virtual-for-directive/virtual-for.sample.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ElementRef, ViewChild, Injectable, OnInit, AfterViewInit } from '@angular/core';
1+
import { Component, ElementRef, ViewChild, Injectable, OnInit, AfterViewInit, ViewEncapsulation } from '@angular/core';
22
import { BehaviorSubject, Observable } from 'rxjs';
33
import { map } from 'rxjs/operators';
44
import { Http } from '@angular/http';
@@ -8,7 +8,9 @@ import { RemoteService } from '../shared/remote.service';
88

99
@Component({
1010
selector: 'app-virt-for-sample',
11-
templateUrl: 'virtual-for.sample.html'
11+
templateUrl: 'virtual-for.sample.html',
12+
styleUrls: ['virtual-for.sample.css'],
13+
encapsulation: ViewEncapsulation.None
1214
})
1315
export class VirtualForSampleComponent implements OnInit, AfterViewInit {
1416
search1: string;
@@ -52,7 +54,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
5254
link: '#',
5355
phone: '770-504-2217',
5456
text: 'Terrance Orta',
55-
width: 100,
5657
height: 100
5758
}, {
5859
key: 2,
@@ -61,7 +62,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
6162
link: '#',
6263
phone: '423-676-2869',
6364
text: 'Richard Mahoney',
64-
width: 200,
6565
height: 200
6666
}, {
6767
key: 3,
@@ -70,7 +70,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
7070
link: '#',
7171
phone: '859-496-2817',
7272
text: 'Donna Price',
73-
width: 300,
7473
height: 300
7574
}, {
7675
key: 4,
@@ -79,7 +78,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
7978
link: '#',
8079
phone: '901-747-3428',
8180
text: 'Lisa Landers',
82-
width: 200,
8381
height: 200
8482
}, {
8583
key: 5,
@@ -88,7 +86,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
8886
link: '#',
8987
phone: '573-394-9254',
9088
text: 'Dorothy H. Spencer',
91-
width: 200,
9289
height: 200
9390
}, {
9491
key: 6,
@@ -97,7 +94,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
9794
link: '#',
9895
phone: '323-668-1482',
9996
text: 'Stephanie May',
100-
width: 100,
10197
height: 100
10298
}, {
10399
key: 7,
@@ -106,7 +102,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
106102
link: '#',
107103
phone: '401-661-3742',
108104
text: 'Marianne Taylor',
109-
width: 100,
110105
height: 100
111106
}, {
112107
key: 8,
@@ -115,7 +110,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
115110
link: '#',
116111
phone: '662-374-2920',
117112
text: 'Tammie Alvarez',
118-
width: 300,
119113
height: 300
120114
}, {
121115
key: 9,
@@ -124,7 +118,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
124118
link: '#',
125119
phone: '240-455-2267',
126120
text: 'Charlotte Flores',
127-
width: 200,
128121
height: 200
129122
}, {
130123
key: 10,
@@ -133,7 +126,6 @@ export class VirtualForSampleComponent implements OnInit, AfterViewInit {
133126
link: '#',
134127
phone: '724-742-0979',
135128
text: 'Ward Riley',
136-
width: 100,
137129
height: 100
138130
}];
139131
for (let i = 10; i < 1e5; i++) {

0 commit comments

Comments
 (0)