Skip to content

Commit

Permalink
Fixing problem with externally controlling expanded rows.
Browse files Browse the repository at this point in the history
Changing the "expanding" option was not changing which rows were selected. Setting an initial list of expanded rows worked, but modifying that list through the props to BootstrapTable did not work.

The value being passed down to TableBody is `this.state.expanding`, but that is only set from props as part of the constructor, so changes to props.options.expanding of an already mounted BootstrapTable weren't being taken into account.

I've added some handling in componentWillReceiveProps to deal with change to `options.expanding`. I've copied the pattern used for the pagination options.
  • Loading branch information
dangerbell committed Apr 4, 2017
1 parent 00dab2a commit a1996ff
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ class BootstrapTable extends Component {
});
}

// If setting the expanded rows is being handled externally
// then overwrite the current expanded rows.
if (this.props.options.expanding !== options.expanding) {
this.setState({
expanding: options.expanding || []
});
}

if (selectRow && selectRow.selected) {
// set default select rows to store.
const copy = selectRow.selected.slice();
Expand Down

0 comments on commit a1996ff

Please sign in to comment.