From c1fe6ecec859ee68bf3bc29f728b5aaff9e77801 Mon Sep 17 00:00:00 2001 From: mertsincan Date: Wed, 12 Aug 2020 10:50:30 +0300 Subject: [PATCH] Fixed #1505 - Add index parameter to onRowEditInit and onRowSave callbacks on DataTable --- src/components/datatable/BodyRow.js | 10 ++++++---- src/components/datatable/DataTable.d.ts | 4 ++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/datatable/BodyRow.js b/src/components/datatable/BodyRow.js index bedab05b84..eaf94a4881 100644 --- a/src/components/datatable/BodyRow.js +++ b/src/components/datatable/BodyRow.js @@ -172,7 +172,8 @@ export class BodyRow extends Component { if (this.props.onRowEditInit) { this.props.onRowEditInit({ originalEvent: event, - data: this.props.rowData + data: this.props.rowData, + index: this.props.rowIndex }); } @@ -193,7 +194,8 @@ export class BodyRow extends Component { if (this.props.onRowEditSave) { this.props.onRowEditSave({ originalEvent: event, - data: this.props.rowData + data: this.props.rowData, + index: this.props.rowIndex }); } @@ -227,7 +229,7 @@ export class BodyRow extends Component { 'p-highlight-contextmenu': this.props.contextMenuSelected }; - if(this.props.rowClassName) { + if (this.props.rowClassName) { let rowClassNameCondition = this.props.rowClassName(this.props.rowData); conditionalClassNames = {...conditionalClassNames, ...rowClassNameCondition}; } @@ -253,7 +255,7 @@ export class BodyRow extends Component { let cell = ; cells.push(cell); diff --git a/src/components/datatable/DataTable.d.ts b/src/components/datatable/DataTable.d.ts index 614edaae2e..a4b7b6c0ce 100644 --- a/src/components/datatable/DataTable.d.ts +++ b/src/components/datatable/DataTable.d.ts @@ -92,8 +92,8 @@ interface DataTableProps { onRowReorder?(e: {originalEvent: Event, value: any, dragIndex: number, dropIndex: number}): void; onValueChange?(value: any[]): void; rowEditorValidator?(rowData: any): boolean; - onRowEditInit?(e: {originalEvent: Event, data: any}): void; - onRowEditSave?(e: {originalEvent: Event, data: any}): void; + onRowEditInit?(e: {originalEvent: Event, data: any, index: number}): void; + onRowEditSave?(e: {originalEvent: Event, data: any, index: number}): void; onRowEditCancel?(e: {originalEvent: Event, data: any, index: number}): void; exportFunction?(e: {data: any, field: string}): any; customSaveState?(state: any): void;