Skip to content

Commit 146e0d9

Browse files
committed
chore(*): Always include parentRowData in the arguments
1 parent 8e12bd3 commit 146e0d9

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
216216
owner: this.layout,
217217
parentID: this.data.rowID,
218218
grid: this.hGrid,
219-
parentRowData: !childGridData?.length ? this.data.parentRowData : undefined,
219+
parentRowData: this.data.parentRowData,
220220
});
221221
}
222222

@@ -234,7 +234,7 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
234234
owner: this.layout,
235235
parentID: this.data.rowID,
236236
grid: this.hGrid,
237-
parentRowData: !this.hGrid.data.length ? this.data.parentRowData : undefined,
237+
parentRowData: this.data.parentRowData,
238238
});
239239

240240
this.hGrid.cdr.detectChanges();

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

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -686,14 +686,12 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
686686
fixture.detectChanges();
687687
const childGrids = hierarchicalGrid.gridAPI.getChildGrids(false);
688688
const childRows = fixture.debugElement.queryAll(By.directive(IgxChildGridRowComponent));
689-
expect(childGrids.length).toBe(3);
690-
expect(childRows.length).toBe(3);
689+
expect(childGrids.length).toBe(2);
690+
expect(childRows.length).toBe(2);
691691
const ri1 = fixture.componentInstance.rowIsland1;
692692
const ri2 = fixture.componentInstance.rowIsland2;
693-
const ri3 = fixture.componentInstance.rowIsland3;
694693
expect(childRows[0].componentInstance.layout).toBe(ri1);
695694
expect(childRows[1].componentInstance.layout).toBe(ri2);
696-
expect(childRows[2].componentInstance.layout).toBe(ri3);
697695
});
698696

699697
it('should display correct data for sibling row islands', () => {
@@ -867,21 +865,18 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
867865
fixture.detectChanges();
868866

869867
const children = hierarchicalGrid.gridAPI.getChildGrids(true);
870-
expect(children.length).toBe(3);
868+
expect(children.length).toBe(2);
871869
const child1 = children[0] as IgxHierarchicalGridComponent;
872870
const child2 = children[1] as IgxHierarchicalGridComponent;
873-
const child3 = children[2] as IgxHierarchicalGridComponent;
874871
expect(child1._destroyed).toBeFalsy();
875872
expect(child2._destroyed).toBeFalsy();
876-
expect(child3._destroyed).toBeFalsy();
877873
hierarchicalGrid.verticalScrollContainer.scrollTo(hierarchicalGrid.dataView.length - 1);
878874
await wait();
879875
fixture.detectChanges();
880876

881877
// check that we have child is not destroyed
882878
expect(child1._destroyed).toBeFalsy();
883879
expect(child2._destroyed).toBeFalsy();
884-
expect(child3._destroyed).toBeFalsy();
885880

886881
// destroy hgrid
887882
fixture.destroy();
@@ -1125,30 +1120,20 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
11251120
expect(summaryCell.textContent.trim()).toEqual('');
11261121
}));
11271122

1128-
it('should verify gridCreated and gridInitialized events emit correct parentRowData for grids with and without data.', () => {
1123+
it('should verify gridCreated and gridInitialized events emit correct parentRowData', () => {
11291124
const row = hierarchicalGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
1130-
const ri1 = fixture.componentInstance.rowIsland1;
1131-
const ri3 = fixture.componentInstance.rowIsland3;
1125+
const rowIsland = fixture.componentInstance.rowIsland1;
11321126

1133-
spyOn(ri1.gridCreated, 'emit').and.callThrough();
1134-
spyOn(ri1.gridInitialized, 'emit').and.callThrough();
1135-
spyOn(ri3.gridCreated, 'emit').and.callThrough();
1136-
spyOn(ri3.gridInitialized, 'emit').and.callThrough();
1127+
spyOn(rowIsland.gridCreated, 'emit').and.callThrough();
1128+
spyOn(rowIsland.gridInitialized, 'emit').and.callThrough();
11371129

11381130
UIInteractions.simulateClickAndSelectEvent(row.expander);
11391131
fixture.detectChanges();
11401132

1141-
// Verify parentRowData is undefined for grids with existing data
1142-
expect(ri1.gridCreated.emit).toHaveBeenCalledTimes(1);
1143-
expect(ri1.gridCreated.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: undefined }));
1144-
expect(ri1.gridInitialized.emit).toHaveBeenCalledTimes(1);
1145-
expect(ri1.gridInitialized.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: undefined }));
1146-
1147-
// Verify parentRowData is defined for grids without data
1148-
expect(ri3.gridCreated.emit).toHaveBeenCalledTimes(1);
1149-
expect(ri3.gridCreated.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: row.data }));
1150-
expect(ri3.gridInitialized.emit).toHaveBeenCalledTimes(1);
1151-
expect(ri3.gridInitialized.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: row.data }));
1133+
expect(rowIsland.gridCreated.emit).toHaveBeenCalledTimes(1);
1134+
expect(rowIsland.gridCreated.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: row.data }));
1135+
expect(rowIsland.gridInitialized.emit).toHaveBeenCalledTimes(1);
1136+
expect(rowIsland.gridInitialized.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: row.data }));
11521137
});
11531138
});
11541139

@@ -2015,14 +2000,12 @@ export class IgxHierarchicalGridTestBaseComponent {
20152000
<igx-column field="Col2"></igx-column>
20162001
<igx-column field="Col3"></igx-column>
20172002
</igx-row-island>
2018-
<igx-row-island [key]="'noData'" #rowIsland3></igx-row-island>
20192003
</igx-hierarchical-grid>`,
20202004
imports: [IgxHierarchicalGridComponent, IgxColumnComponent, IgxRowIslandComponent]
20212005
})
20222006
export class IgxHierarchicalGridMultiLayoutComponent extends IgxHierarchicalGridTestBaseComponent {
20232007
@ViewChild('rowIsland1', { read: IgxRowIslandComponent, static: true }) public rowIsland1: IgxRowIslandComponent;
20242008
@ViewChild('rowIsland2', { read: IgxRowIslandComponent, static: true }) public override rowIsland2: IgxRowIslandComponent;
2025-
@ViewChild('rowIsland3', { read: IgxRowIslandComponent, static: true }) public rowIsland3: IgxRowIslandComponent;
20262009
public height = '100px';
20272010
public toggleColumns = true;
20282011
}

0 commit comments

Comments
 (0)