Skip to content

Commit 974e6ad

Browse files
feat(hierarchical-grid): add parentRowData to IGridCreatedEventArgs (#15658)
* feat(hierarchical-grid): add parentRowData to IGridCreatedEventArgs * chore(*): Always include parentRowData in the arguments * chore(*): clean up leftover --------- Co-authored-by: Hristo <[email protected]>
1 parent 4b378c9 commit 974e6ad

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ export interface IGridCreatedEventArgs extends IBaseEventArgs {
77
owner: IgxRowIslandComponent;
88
parentID: any;
99
grid: IgxHierarchicalGridComponent;
10+
parentRowData?: any;
1011
}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
214214
this.layout.gridCreated.emit({
215215
owner: this.layout,
216216
parentID: this.data.rowID,
217-
grid: this.hGrid
217+
grid: this.hGrid,
218+
parentRowData: this.data.parentRowData,
218219
});
219220
}
220221

@@ -231,7 +232,8 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
231232
this.layout.gridInitialized.emit({
232233
owner: this.layout,
233234
parentID: this.data.rowID,
234-
grid: this.hGrid
235+
grid: this.hGrid,
236+
parentRowData: this.data.parentRowData,
235237
});
236238

237239
this.hGrid.cdr.detectChanges();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class IgxGridHierarchicalPipe implements PipeTransform {
4949
childGridsData[childKey] = childData;
5050
});
5151
if (grid.gridAPI.get_row_expansion_state(v)) {
52-
result.push({ rowID: primaryKey ? v[primaryKey] : v, childGridsData });
52+
result.push({ rowID: primaryKey ? v[primaryKey] : v, childGridsData, parentRowData: v });
5353
}
5454
});
5555
return result;

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,22 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
11191119
expect(getterSpy).toHaveBeenCalledTimes(7);
11201120
expect(summaryCell.textContent.trim()).toEqual('');
11211121
}));
1122+
1123+
it('should verify gridCreated and gridInitialized events emit correct parentRowData', () => {
1124+
const row = hierarchicalGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
1125+
const rowIsland = fixture.componentInstance.rowIsland1;
1126+
1127+
spyOn(rowIsland.gridCreated, 'emit').and.callThrough();
1128+
spyOn(rowIsland.gridInitialized, 'emit').and.callThrough();
1129+
1130+
UIInteractions.simulateClickAndSelectEvent(row.expander);
1131+
fixture.detectChanges();
1132+
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 }));
1137+
});
11221138
});
11231139

11241140
describe('IgxHierarchicalGrid Children Sizing #hGrid', () => {

0 commit comments

Comments
 (0)