Skip to content

Commit

Permalink
fix(grid): move row edit warning to crudService.beginRowEdit, #5010
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorSlavov committed Jun 13, 2019
1 parent 9e56b7b commit 265fa97
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
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
19 changes: 1 addition & 18 deletions projects/igniteui-angular/src/lib/grids/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 265fa97

Please sign in to comment.