Skip to content

Commit 6e5e587

Browse files
authored
fix(IgxGrid): Fix event args for rowAdded too. Update test. (#14119)
1 parent 09ff9b9 commit 6e5e587

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

projects/igniteui-angular/src/lib/grids/common/crud.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class IgxAddRow extends IgxEditRow {
9393
const args = super.createRowEditEventArgs(includeNewValue, event);
9494
args.oldValue = null;
9595
args.isAddRow = true;
96+
args.rowData = this.newData ?? this.data;
9697
return args;
9798
}
9899

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

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { TestBed, fakeAsync, tick, waitForAsync } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { IgxGridComponent } from './grid.component';
6-
import { IGridEditDoneEventArgs, IGridEditEventArgs, IRowDataCancelableEventArgs } from '../common/events';
6+
import { IGridEditDoneEventArgs, IGridEditEventArgs, IRowDataCancelableEventArgs, IRowDataEventArgs } from '../common/events';
77
import { IgxColumnComponent } from '../columns/column.component';
88
import { DisplayDensity } from '../../core/density';
99
import { UIInteractions, wait } from '../../test-utils/ui-interactions.spec';
@@ -299,8 +299,9 @@ describe('IgxGrid - Row Editing #grid', () => {
299299
expect(grid.rowEditDone.emit).toHaveBeenCalledWith(rowDoneArgs);
300300
});
301301

302-
it('Emit rowAdd event with proper arguments', () => {
302+
it('Emit rowAdd and rowAdded event with proper arguments', () => {
303303
spyOn(grid.rowAdd, 'emit').and.callThrough();
304+
spyOn(grid.rowAdded, 'emit').and.callThrough();
304305
// start add row
305306
grid.beginAddRowById(null);
306307
fix.detectChanges();
@@ -336,7 +337,16 @@ describe('IgxGrid - Row Editing #grid', () => {
336337
owner: grid,
337338
isAddRow: true
338339
}
340+
341+
const rowAddedArgs: IRowDataEventArgs = {
342+
rowData: { ProductID: generatedId, ProductName: "NewValue"},
343+
data: { ProductID: generatedId, ProductName: "NewValue"},
344+
primaryKey: generatedId,
345+
rowKey: generatedId,
346+
owner: grid
347+
};
339348
expect(grid.rowAdd.emit).toHaveBeenCalledWith(rowAddArgs);
349+
expect(grid.rowAdded.emit).toHaveBeenCalledWith(rowAddedArgs);
340350
});
341351

342352
it('Should display the banner below the edited row if it is not the last one', () => {

0 commit comments

Comments
 (0)