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
3 changes: 3 additions & 0 deletions projects/igniteui-angular/src/lib/core/grid-selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ export class IgxGridCRUDService {
}

beginRowEdit() {
if (this.grid.rowEditable && (this.grid.primaryKey === undefined || this.grid.primaryKey === null)) {
console.warn('The grid must have a `primaryKey` specified when using `rowEditable`!');
}
this.row = this.createRow(this.cell);
const args = {
rowID: this.row.id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
* @memberof IgxGridBaseComponent
*/
set rowEditable(val: boolean) {
if (val && (this.primaryKey === undefined || this.primaryKey === null)) {
console.warn('The grid must have a `primaryKey` specified when using `rowEditable`!');
}
this._rowEditable = val;
if (this.gridAPI.grid) {
this.refreshGridState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1391,22 +1391,21 @@ describe('IgxGrid Component Tests', () => {
grid.rowEditable = true;
fix.detectChanges();
tick(16);
expect(console.warn).toHaveBeenCalledWith('The grid must have a `primaryKey` specified when using `rowEditable`!');
expect(console.warn).toHaveBeenCalledTimes(1);
// Throws warinig but still sets the property correctly
expect(grid.rowEditable).toBeTruthy();

const cell = grid.getRowByIndex(2).cells.toArray()[1].nativeElement;
spyOn(grid, 'openRowOverlay');
cell.dispatchEvent(new Event('focus'));
tick(16);
fix.detectChanges();
grid.primaryKey = 'ProductID';
grid.rowEditable = false;
fix.detectChanges();
cell.dispatchEvent(new Event('dblclick'));
tick(16);
grid.rowEditable = true;
fix.detectChanges();
tick(16);
expect(console.warn).toHaveBeenCalledWith('The grid must have a `primaryKey` specified when using `rowEditable`!');
expect(console.warn).toHaveBeenCalledTimes(1);
expect(grid.rowEditable).toBeTruthy();
// Still calls openRowOverlay, just logs the warning
expect(grid.openRowOverlay).toHaveBeenCalled();
}));
it('Should be able to enter edit mode on dblclick, enter and f2', fakeAsync(() => {
const fix = TestBed.createComponent(IgxGridRowEditingComponent);
Expand Down