From 9bf8a35f026d15e66a8b8e0d68e00825e5d1ad5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=87a=C4=9Fatay=20=C3=87ivici?= Date: Mon, 27 Mar 2017 15:09:58 +0300 Subject: [PATCH] Fixed #2104 --- components/common/shared.ts | 5 ++++- components/datatable/datatable.ts | 12 ++++++------ showcase/demo/datatable/datatabledemo.html | 9 ++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/components/common/shared.ts b/components/common/shared.ts index 2e20a94caf9..4001218b820 100644 --- a/components/common/shared.ts +++ b/components/common/shared.ts @@ -263,6 +263,8 @@ export class ColumnEditorTemplateLoader implements OnInit, OnDestroy { @Input() column: any; @Input() rowData: any; + + @Input() rowIndex: any; view: EmbeddedViewRef; @@ -271,7 +273,8 @@ export class ColumnEditorTemplateLoader implements OnInit, OnDestroy { ngOnInit() { this.view = this.viewContainer.createEmbeddedView(this.column.editorTemplate, { '\$implicit': this.column, - 'rowData': this.rowData + 'rowData': this.rowData, + 'rowIndex': this.rowIndex }); } diff --git a/components/datatable/datatable.ts b/components/datatable/datatable.ts index a955549b3f3..c621a735b82 100644 --- a/components/datatable/datatable.ts +++ b/components/datatable/datatable.ts @@ -172,8 +172,8 @@ export class ColumnFooters {
- + (keydown)="dt.onCellEditorKeydown($event, col, rowData, colIndex, rowIndex)" class="ui-inputtext ui-widget ui-state-default ui-corner-all"/> +
@@ -1542,13 +1542,13 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni this.domHandler.removeClass(cell, 'ui-cell-editing'); } - onCellEditorKeydown(event, column: Column, rowData: any, colIndex: number) { + onCellEditorKeydown(event, column: Column, rowData: any, colIndex: number, rowIndex: number) { if(this.editable) { - this.onEdit.emit({originalEvent: event, column: column, data: rowData}); + this.onEdit.emit({originalEvent: event, column: column, data: rowData, index: rowIndex}); //enter if(event.keyCode == 13) { - this.onEditComplete.emit({column: column, data: rowData}); + this.onEditComplete.emit({column: column, data: rowData, index: rowIndex}); this.renderer.invokeElementMethod(event.target, 'blur'); this.switchCellToViewMode(event.target); event.preventDefault(); @@ -1556,7 +1556,7 @@ export class DataTable implements AfterViewChecked,AfterViewInit,AfterContentIni //escape else if(event.keyCode == 27) { - this.onEditCancel.emit({column: column, data: rowData}); + this.onEditCancel.emit({column: column, data: rowData, index: rowIndex}); this.renderer.invokeElementMethod(event.target, 'blur'); this.switchCellToViewMode(event.target); event.preventDefault(); diff --git a/showcase/demo/datatable/datatabledemo.html b/showcase/demo/datatable/datatabledemo.html index 57471943ef9..13a4056394b 100644 --- a/showcase/demo/datatable/datatabledemo.html +++ b/showcase/demo/datatable/datatabledemo.html @@ -1273,19 +1273,22 @@

Events

onEdit event.originalEvent: Browser event event.column: Column object of the cell
- event.data: Row data + event.data: Row data
+ event.index: Row index Callback to invoke when cell data is being edited. onEditComplete event.column: Column object of the cell
- event.data: Row data + event.data: Row data
+ event.index: Row index Callback to invoke when cell edit is completed. onEditCancel event.column: Column object of the cell
- event.data: Row data + event.data: Row data
+ event.index: Row index Callback to invoke when cell edit is cancelled with escape key.