Skip to content

Commit

Permalink
fix #1299
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed May 16, 2017
1 parent 61ff06b commit f54ebc3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
8 changes: 7 additions & 1 deletion src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,11 @@ class BootstrapTable extends Component {
});
}

handleExpandRow = expanding => {
handleExpandRow = (expanding, rowKey, isRowExpanding) => {
const { onExpand } = this.props.options;
if (onExpand) {
onExpand(rowKey, !isRowExpanding);
}
this.setState({ expanding, reset: false }, () => {
this._adjustHeaderWidth();
});
Expand Down Expand Up @@ -1451,6 +1455,7 @@ BootstrapTable.propTypes = {
expandRowBgColor: PropTypes.string,
expandBy: PropTypes.string,
expanding: PropTypes.array,
onExpand: PropTypes.func,
onlyOneExpanding: PropTypes.bool,
beforeShowError: PropTypes.func,
printToolBar: PropTypes.bool
Expand Down Expand Up @@ -1598,6 +1603,7 @@ BootstrapTable.defaultProps = {
expandRowBgColor: undefined,
expandBy: Const.EXPAND_BY_ROW,
expanding: [],
onExpand: undefined,
onlyOneExpanding: false,
beforeShowError: undefined,
printToolBar: true
Expand Down
10 changes: 6 additions & 4 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,15 +316,17 @@ class TableBody extends Component {
if configure as expanding by column */
(expandBy === Const.EXPAND_BY_COL && columnIndex < 0) ||
(expandBy === Const.EXPAND_BY_COL && columns[columnIndex].expandable))) {
const rowKey = this.props.data[rowIndex - 1][keyField];
let expanding = this.props.expanding;
if (expanding.indexOf(rowKey) > -1) {
const rowKey = this.props.data[rowIndex - 1][keyField];
const isRowExpanding = expanding.indexOf(rowKey) > -1;

if (isRowExpanding) { // collapse
expanding = expanding.filter(k => k !== rowKey);
} else {
} else { // expand
if (onlyOneExpanding) expanding = [ rowKey ];
else expanding.push(rowKey);
}
this.props.onExpand(expanding);
this.props.onExpand(expanding, rowKey, isRowExpanding);
}
}

Expand Down

0 comments on commit f54ebc3

Please sign in to comment.