Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Mar 24, 2016
2 parents 4b34f68 + 7b5bc39 commit 85b3e72
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions examples/js/selection/externally-managed-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,21 @@ export default class ExternallyManagedSelection extends React.Component {
constructor(props) {
super(props);
this.state = {
selected: []
selected: [],
currPage: 1
};
}

render() {
const {
currPage
} = this.state;
const onRowSelect = ({ id }, isSelected) => {
if (isSelected && this.state.selected.length !== 2) {
this.setState({ selected: [ ...this.state.selected, id ].sort() });
this.setState({
selected: [ ...this.state.selected, id ].sort(),
currPage: this.refs.table.state.currPage
});
} else {
this.setState({ selected: this.state.selected.filter(it => it !== id) });
}
Expand All @@ -47,12 +54,13 @@ export default class ExternallyManagedSelection extends React.Component {
const options = {
sizePerPageList: [ 5, 10, 15, 20 ],
sizePerPage: 10,
page: currPage,
sortName: 'id',
sortOrder: 'desc'
};

return (
<BootstrapTable data={ products } selectRow={ selectRowProp } pagination={ true } options={ options }>
<BootstrapTable ref='table' data={ products } selectRow={ selectRowProp } pagination={ true } options={ options }>
<TableHeaderColumn dataField='id' isKey={ true }>Product ID</TableHeaderColumn>
<TableHeaderColumn dataField='name'>Product Name</TableHeaderColumn>
<TableHeaderColumn dataField='price'>Product Price</TableHeaderColumn>
Expand Down

0 comments on commit 85b3e72

Please sign in to comment.