diff --git a/projects/igniteui-angular/src/lib/core/grid-selection.ts b/projects/igniteui-angular/src/lib/core/grid-selection.ts index 0986efd12bd..6aee9472269 100644 --- a/projects/igniteui-angular/src/lib/core/grid-selection.ts +++ b/projects/igniteui-angular/src/lib/core/grid-selection.ts @@ -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, diff --git a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts index 24de0f3a69a..6a224cff404 100644 --- a/projects/igniteui-angular/src/lib/grids/grid-base.component.ts +++ b/projects/igniteui-angular/src/lib/grids/grid-base.component.ts @@ -243,7 +243,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements private _locale = null; private _observer: MutationObserver; private _destroyed = false; - private _primaryKey = null; private overlayIDs = []; /** * An accessor that sets the resource strings. @@ -599,7 +598,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements set rowEditable(val: boolean) { this._rowEditable = val; if (this.gridAPI.grid) { - this.checkEditKey(val); this.refreshGridState(); } } @@ -753,16 +751,8 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements */ @WatchChanges() @Input() - public set primaryKey(val: any) { - this._primaryKey = val; - if (this.gridAPI.grid) { - this.checkEditKey(this._rowEditable); - } - } + public primaryKey; - public get primaryKey(): any { - return this._primaryKey; - } /** * An @Input property that sets the message displayed when there are no records. * ```html @@ -2596,12 +2586,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements this.hideOverlays(); } - private checkEditKey(val: boolean): void { - if (val && (this.primaryKey === undefined || this.primaryKey === null)) { - console.warn('The grid must have a `primaryKey` specified when using `rowEditable`!'); - } - } - /** * @hidden * @internal @@ -2717,7 +2701,6 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements this.calcWidth = this._width && this._width.indexOf('%') === -1 ? parseInt(this._width, 10) : 0; this.shouldGenerate = this.autoGenerate; this._scrollWidth = this.getScrollWidth(); - this.checkEditKey(this._rowEditable); } protected setupColumns() {