Skip to content

Commit c4c1b7f

Browse files
committed
fix #1166
1 parent 387118c commit c4c1b7f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/BootstrapTable.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ class BootstrapTable extends Component {
411411
withoutNoDataText={ this.props.options.withoutNoDataText }
412412
expanding={ this.state.expanding }
413413
onExpand={ this.handleExpandRow }
414+
onlyOneExpanding={ this.props.options.onlyOneExpanding }
414415
beforeShowError={ this.props.options.beforeShowError }
415416
keyBoardNav={ this.props.keyBoardNav }
416417
onNavigateCell={ this.handleNavigateCell }
@@ -1385,6 +1386,7 @@ BootstrapTable.propTypes = {
13851386
expandRowBgColor: PropTypes.string,
13861387
expandBy: PropTypes.string,
13871388
expanding: PropTypes.array,
1389+
onlyOneExpanding: PropTypes.bool,
13881390
beforeShowError: PropTypes.func,
13891391
printToolBar: PropTypes.bool
13901392
}),
@@ -1529,6 +1531,7 @@ BootstrapTable.defaultProps = {
15291531
expandRowBgColor: undefined,
15301532
expandBy: Const.EXPAND_BY_ROW,
15311533
expanding: [],
1534+
onlyOneExpanding: false,
15321535
beforeShowError: undefined,
15331536
printToolBar: true
15341537
},

src/TableBody.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,8 @@ class TableBody extends Component {
303303
expandableRow,
304304
selectRow: {
305305
clickToExpand
306-
}
306+
},
307+
onlyOneExpanding
307308
} = this.props;
308309
const selectRowAndExpand = this._isSelectRowDefined() && !clickToExpand ? false : true;
309310
columnIndex = this._isSelectRowDefined() ? columnIndex - 1 : columnIndex;
@@ -320,7 +321,8 @@ class TableBody extends Component {
320321
if (expanding.indexOf(rowKey) > -1) {
321322
expanding = expanding.filter(k => k !== rowKey);
322323
} else {
323-
expanding.push(rowKey);
324+
if (onlyOneExpanding) expanding = [ rowKey ];
325+
else expanding.push(rowKey);
324326
}
325327
this.props.onExpand(expanding);
326328
}
@@ -489,6 +491,7 @@ TableBody.propTypes = {
489491
expandBy: PropTypes.string,
490492
expanding: PropTypes.array,
491493
onExpand: PropTypes.func,
494+
onlyOneExpanding: PropTypes.bool,
492495
beforeShowError: PropTypes.func,
493496
keyBoardNav: PropTypes.oneOfType([ PropTypes.bool, PropTypes.object ]),
494497
x: PropTypes.number,

0 commit comments

Comments
 (0)