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 a738eb0 commit ae2d29e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 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
27 changes: 5 additions & 22 deletions projects/igniteui-angular/src/lib/grids/grid-base.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export interface IRowDragEndEventArgs {
export interface IRowDragStartEventArgs extends CancelableEventArgs {
owner: IgxDragDirective;
dragData: IgxRowComponent<IgxGridBaseComponent & IGridDataBindable>;
}
}

export enum GridSummaryPosition {
top = 'top',
Expand Down Expand Up @@ -247,7 +247,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 @@ -605,7 +604,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 @@ -759,16 +757,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 @@ -2595,12 +2585,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 @@ -2716,7 +2700,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 Expand Up @@ -3411,7 +3394,7 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
this._moveColumns(column, dropTarget, position);
this.cdr.detectChanges();
if (this.hasColumnLayouts) {
this.columns.filter(x => x.columnLayout).forEach(x => x.populateVisibleIndexes());
this.columns.filter(x => x.columnLayout).forEach( x => x.populateVisibleIndexes());
}

const args = {
Expand Down Expand Up @@ -4911,13 +4894,13 @@ export abstract class IgxGridBaseComponent extends DisplayDensityBase implements
&& this.navigation.isColumnLeftFullyVisible(visibleColIndex))) {
if (this.navigation.shouldPerformVerticalScroll(rowIndex, visibleColIndex)) {
this.navigation.performVerticalScrollToCell(rowIndex, visibleColIndex,
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
() => { this.executeCallback(rowIndex, visibleColIndex, cb); } );
} else {
this.executeCallback(rowIndex, visibleColIndex, cb);
}
} else {
this.navigation.performHorizontalScrollToCell(rowIndex, visibleColIndex, false,
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
() => { this.executeCallback(rowIndex, visibleColIndex, cb); });
}
}

Expand Down

0 comments on commit ae2d29e

Please sign in to comment.