Skip to content

Commit

Permalink
fix(igxCell): Expose and use getter and setter for editValue (#2958)
Browse files Browse the repository at this point in the history
  • Loading branch information
dkamburov committed Nov 29, 2018
1 parent a868420 commit adf8335
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
8 changes: 4 additions & 4 deletions projects/igniteui-angular/src/lib/grids/cell.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
<ng-template #inlineEditor let-cell="cell">
<ng-container *ngIf="column.dataType === 'string'">
<igx-input-group displayDensity="compact">
<input igxInput [(ngModel)]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [igxFocus]="focused">
<input igxInput [(ngModel)]="editValue" [igxFocus]="focused">
</igx-input-group>
</ng-container>
<ng-container *ngIf="column.dataType === 'number'">
<igx-input-group displayDensity="compact">
<input igxInput [(ngModel)]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [igxFocus]="focused" type="number">
<input igxInput [(ngModel)]="editValue" [igxFocus]="focused" type="number">
</igx-input-group>
</ng-container>
<ng-container *ngIf="column.dataType === 'boolean'">
<igx-checkbox (change)="gridAPI.get_cell_inEditMode(gridID).cell.editValue = $event.checked" [value]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [checked]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [igxFocus]="focused" [disableRipple]="true"></igx-checkbox>
<igx-checkbox (change)="editValue" [value]="editValue" [checked]="editValue" [igxFocus]="focused" [disableRipple]="true"></igx-checkbox>
</ng-container>
<ng-container *ngIf="column.dataType === 'date'">
<igx-datePicker (onSelection)="gridAPI.get_cell_inEditMode(gridID).cell.editValue = $event" [value]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [igxFocus]="focused" [labelVisibility]="false"></igx-datePicker>
<igx-datePicker (onSelection)="editValue = $event" [value]="editValue" [igxFocus]="focused" [labelVisibility]="false"></igx-datePicker>
</ng-container>
</ng-template>
<ng-container *ngTemplateOutlet="template; context: context">
Expand Down
35 changes: 28 additions & 7 deletions projects/igniteui-angular/src/lib/grids/cell.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
return;
}
if (this.column.editable && value) {
this.editValue = this.value;
this.gridAPI.set_cell_inEditMode(this.gridID, this);
if (this.highlight && this.grid.lastSearchInfo.searchText) {
this.highlight.observe();
}
this.editValue = this.value;
} else {
this.gridAPI.escape_editMode(this.gridID, this.cellID);
}
Expand Down Expand Up @@ -482,9 +482,30 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
private highlight: IgxTextHighlightDirective;

/**
* @hidden
* Sets the current edit value while a cell is in edit mode.
* Only for cell editing mode.
* ```typescript
* let isLastPinned = this.cell.isLastPinned;
* ```
* @memberof IgxGridCellComponent
*/
public editValue;
public set editValue(value) {
if (this.gridAPI.get_cell_inEditMode(this.gridID)) {
this.gridAPI.get_cell_inEditMode(this.gridID).cell.editValue = value;
}
}

/**
* Gets the current edit value while a cell is in edit mode.
* Only for cell editing mode.
* ```typescript
* let editValue = this.cell.editValue;
* ```
* @memberof IgxGridCellComponent
*/
public get editValue() {
return this.gridAPI.get_cell_inEditMode(this.gridID).cell.editValue;
}
public focused = false;
protected isSelected = false;
private cellSelectionID: string;
Expand Down Expand Up @@ -704,7 +725,7 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
const column = this.gridAPI.get(this.gridID).columns[editCell.cellID.columnID];

if (column.inlineEditorTemplate === undefined && (
(column.dataType === DataType.Boolean && (key !== KEYS.SPACE && key !== KEYS.SPACE_IE))
(column.dataType === DataType.Boolean && (key !== KEYS.SPACE && key !== KEYS.SPACE_IE))
|| column.dataType === DataType.Date)) {
event.preventDefault();
}
Expand All @@ -727,11 +748,11 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
(this.gridAPI as any).trigger_row_expansion_toggle(
this.gridID, this.row.treeRow, !this.row.expanded, event, this.visibleColumnIndex);
}
return;
return;
}
}

const args = {cell: this, groupRow: null, event: event, cancel: false };
const args = { cell: this, groupRow: null, event: event, cancel: false };
this.grid.onFocusChange.emit(args);
if (args.cancel) {
return;
Expand Down Expand Up @@ -904,7 +925,7 @@ export class IgxGridCellComponent implements OnInit, AfterViewInit {
*/
public calculateSizeToFit(range: any): number {
return Math.max(...Array.from(this.nativeElement.children)
.map((child) => getNodeSizeViaRange(range, child)));
.map((child) => getNodeSizeViaRange(range, child)));
}

private isToggleKey(key) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
<ng-template #inlineEditor let-cell="cell">
<ng-container *ngIf="column.dataType === 'string'">
<igx-input-group>
<input igxInput [(ngModel)]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [igxFocus]="focused">
<input igxInput [(ngModel)]="editValue" [igxFocus]="focused">
</igx-input-group>
</ng-container>
<ng-container *ngIf="column.dataType === 'number'">
<igx-input-group>
<input igxInput [(ngModel)]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [igxFocus]="focused" type="number">
<input igxInput [(ngModel)]="editValue" [igxFocus]="focused" type="number">
</igx-input-group>
</ng-container>
<ng-container *ngIf="column.dataType === 'boolean'">
<igx-checkbox (change)="gridAPI.get_cell_inEditMode(gridID).cell.editValue = $event.checked" [value]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [checked]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [disableRipple]="true"></igx-checkbox>
<igx-checkbox (change)="editValue = $event.checked" [value]="editValue" [checked]="editValue" [disableRipple]="true"></igx-checkbox>
</ng-container>
<ng-container *ngIf="column.dataType === 'date'">
<igx-datePicker (onSelection)="gridAPI.get_cell_inEditMode(gridID).cell.editValue = $event" [value]="gridAPI.get_cell_inEditMode(gridID).cell.editValue" [labelVisibility]="false"></igx-datePicker>
<igx-datePicker (onSelection)="editValue = $event" [value]="editValue" [labelVisibility]="false"></igx-datePicker>
</ng-container>
</ng-template>
<ng-container *ngIf="!inEditMode">
Expand Down

0 comments on commit adf8335

Please sign in to comment.