Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ export interface IGridCreatedEventArgs extends IBaseEventArgs {
owner: IgxRowIslandComponent;
parentID: any;
grid: IgxHierarchicalGridComponent;
parentRowData?: any;
}
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
this.layout.gridCreated.emit({
owner: this.layout,
parentID: this.data.rowID,
grid: this.hGrid
grid: this.hGrid,
parentRowData: this.data.parentRowData,
});
}

Expand All @@ -231,7 +232,8 @@ export class IgxChildGridRowComponent implements AfterViewInit, OnInit {
this.layout.gridInitialized.emit({
owner: this.layout,
parentID: this.data.rowID,
grid: this.hGrid
grid: this.hGrid,
parentRowData: this.data.parentRowData,
});

this.hGrid.cdr.detectChanges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class IgxGridHierarchicalPipe implements PipeTransform {
childGridsData[childKey] = childData;
});
if (grid.gridAPI.get_row_expansion_state(v)) {
result.push({ rowID: primaryKey ? v[primaryKey] : v, childGridsData });
result.push({ rowID: primaryKey ? v[primaryKey] : v, childGridsData, parentRowData: v });
}
});
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,22 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
expect(getterSpy).toHaveBeenCalledTimes(7);
expect(summaryCell.textContent.trim()).toEqual('');
}));

it('should verify gridCreated and gridInitialized events emit correct parentRowData', () => {
const row = hierarchicalGrid.gridAPI.get_row_by_index(0) as IgxHierarchicalRowComponent;
const rowIsland = fixture.componentInstance.rowIsland1;

spyOn(rowIsland.gridCreated, 'emit').and.callThrough();
spyOn(rowIsland.gridInitialized, 'emit').and.callThrough();

UIInteractions.simulateClickAndSelectEvent(row.expander);
fixture.detectChanges();

expect(rowIsland.gridCreated.emit).toHaveBeenCalledTimes(1);
expect(rowIsland.gridCreated.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: row.data }));
expect(rowIsland.gridInitialized.emit).toHaveBeenCalledTimes(1);
expect(rowIsland.gridInitialized.emit).toHaveBeenCalledWith(jasmine.objectContaining({ parentRowData: row.data }));
});
});

describe('IgxHierarchicalGrid Children Sizing #hGrid', () => {
Expand Down
Loading