Skip to content

Commit

Permalink
fix #304
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Mar 10, 2016
1 parent 34ffef5 commit 0f30823
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
11 changes: 7 additions & 4 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,14 @@ class BootstrapTable extends React.Component {
this.initTable(nextProps);
if (Array.isArray(nextProps.data)) {
this.store.setData(nextProps.data.slice());
let paginationDom = this.refs.pagination;
let page = paginationDom && paginationDom.getCurrentPage() || nextProps.options.page || 1;
let sizePerPage = paginationDom && paginationDom.getSizePerPage() || nextProps.options.sizePerPage || Const.SIZE_PER_PAGE_LIST[0];
let page = nextProps.options.page || this.state.currPage;
let sizePerPage = nextProps.options.sizePerPage || this.state.sizePerPage;

// #125
if(page > Math.ceil(nextProps.data.length / sizePerPage)) page = 1;
if(!nextProps.options.page &&
page >= Math.ceil(nextProps.data.length / sizePerPage)){
page = 1;
}
let sortInfo = this.store.getSortInfo();
let sortField = nextProps.options.sortName || (sortInfo ? sortInfo.sortField : undefined);
let sortOrder = nextProps.options.sortOrder || (sortInfo ? sortInfo.order : undefined);
Expand Down
8 changes: 0 additions & 8 deletions src/pagination/PaginationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,6 @@ class PaginationList extends React.Component {
}
return pages;
}

getCurrentPage() {
return this.props.currPage;
}

getSizePerPage() {
return this.props.sizePerPage;
}
}
PaginationList.propTypes = {
currPage: React.PropTypes.number,
Expand Down

0 comments on commit 0f30823

Please sign in to comment.