From 29064ff237bc90080763964d250636927d3fc457 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sat, 24 Jun 2017 14:01:46 +0800 Subject: [PATCH] fix #1401 --- src/BootstrapTable.js | 16 ++++++++-------- src/store/TableDataStore.js | 4 +++- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/BootstrapTable.js b/src/BootstrapTable.js index 4b65d97d1..8b8b1697c 100644 --- a/src/BootstrapTable.js +++ b/src/BootstrapTable.js @@ -941,17 +941,17 @@ class BootstrapTable extends Component { } deleteRow(dropRowKeys) { - const { onDeleteRow } = this.props.options; + const dropRow = this.store.getRowByKey(dropRowKeys); + const { onDeleteRow, afterDeleteRow } = this.props.options; + if (onDeleteRow) { - onDeleteRow(dropRowKeys); + onDeleteRow(dropRowKeys, dropRow); } this.store.setSelectedRowKey([]); // clear selected row key - if (this.allowRemote(Const.REMOTE_DROP_ROW)) { - if (this.props.options.afterDeleteRow) { - this.props.options.afterDeleteRow(dropRowKeys); - } + if (this.allowRemote(Const.REMOTE_DROP_ROW) && afterDeleteRow) { + afterDeleteRow(dropRowKeys, dropRow); return; } @@ -981,8 +981,8 @@ class BootstrapTable extends Component { }; }); } - if (this.props.options.afterDeleteRow) { - this.props.options.afterDeleteRow(dropRowKeys); + if (afterDeleteRow) { + afterDeleteRow(dropRowKeys, dropRow); } } diff --git a/src/store/TableDataStore.js b/src/store/TableDataStore.js index dc77c9cd1..add2d6423 100644 --- a/src/store/TableDataStore.js +++ b/src/store/TableDataStore.js @@ -130,9 +130,11 @@ export class TableDataStore { // if (result.length !== 0) return result[0]; // }); const result = []; + if (!keys || keys.length === 0) { + return result; + } for (let i = 0; i < this.data.length; i++) { const d = this.data[i]; - if (!keys || keys.length === 0) break; if (keys.indexOf(d[this.keyField]) > -1) { keys = keys.filter(k => k !== d[this.keyField]); result.push(d);