From 52343759d2525e1d73257977e0402d5c04dff060 Mon Sep 17 00:00:00 2001 From: AllenFang Date: Sat, 6 May 2017 16:28:44 +0800 Subject: [PATCH] fix #1257 --- src/BootstrapTable.js | 3 +++ src/pagination/PaginationList.js | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/BootstrapTable.js b/src/BootstrapTable.js index d014fce0e..0c1384f8c 100644 --- a/src/BootstrapTable.js +++ b/src/BootstrapTable.js @@ -1046,6 +1046,7 @@ class BootstrapTable extends Component { sizePerPageDropDown={ options.sizePerPageDropDown } hidePageListOnlyOnePage={ options.hidePageListOnlyOnePage } paginationPanel={ options.paginationPanel } + keepSizePerPageState={ options.keepSizePerPageState } open={ false }/> ); @@ -1373,6 +1374,7 @@ BootstrapTable.propTypes = { hidePageListOnlyOnePage: PropTypes.bool, alwaysShowAllBtns: PropTypes.bool, withFirstAndLast: PropTypes.bool, + keepSizePerPageState: PropTypes.bool, onSortChange: PropTypes.func, onPageChange: PropTypes.func, onSizePerPageList: PropTypes.func, @@ -1525,6 +1527,7 @@ BootstrapTable.defaultProps = { hidePageListOnlyOnePage: false, alwaysShowAllBtns: false, withFirstAndLast: true, + keepSizePerPageState: false, onSizePerPageList: undefined, noDataText: undefined, withoutNoDataText: false, diff --git a/src/pagination/PaginationList.js b/src/pagination/PaginationList.js index 93c832d4d..d7ce3c7ed 100644 --- a/src/pagination/PaginationList.js +++ b/src/pagination/PaginationList.js @@ -14,7 +14,10 @@ class PaginationList extends Component { } componentWillReceiveProps() { - this.setState({ open: false }); + const { keepSizePerPageState } = this.props; + if (!keepSizePerPageState) { + this.setState({ open: false }); + } } changePage = page => { @@ -25,7 +28,8 @@ class PaginationList extends Component { nextPage, lastPage, firstPage, - sizePerPage + sizePerPage, + keepSizePerPageState } = this.props; if (page === prePage) { @@ -40,6 +44,8 @@ class PaginationList extends Component { page = parseInt(page, 10); } + if (keepSizePerPageState) { this.setState({ open: false }); } + if (page !== currPage) { this.props.changePage(page, sizePerPage); } @@ -56,9 +62,8 @@ class PaginationList extends Component { if (this.props.onSizePerPageList) { this.props.onSizePerPageList(selectSize); } - } else { - this.setState({ open: false }); } + this.setState({ open: false }); } toggleDropDown = () => { @@ -302,7 +307,8 @@ PaginationList.propTypes = { nextPageTitle: PropTypes.string, firstPageTitle: PropTypes.string, lastPageTitle: PropTypes.string, - hidePageListOnlyOnePage: PropTypes.bool + hidePageListOnlyOnePage: PropTypes.bool, + keepSizePerPageState: PropTypes.bool }; PaginationList.defaultProps = {