From 46c93ce88898122678b614c6b90ea97adefea3da Mon Sep 17 00:00:00 2001 From: AllenFang Date: Mon, 19 Oct 2015 00:03:13 +0800 Subject: [PATCH] fix missing pagination when data changed. --- src/BootstrapTable.js | 12 +++++++++--- src/store/TableDataStore.js | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/BootstrapTable.js b/src/BootstrapTable.js index 171ecc6f7..15cdcdc0c 100644 --- a/src/BootstrapTable.js +++ b/src/BootstrapTable.js @@ -58,9 +58,15 @@ class BootstrapTable extends React.Component{ getTableData() { let result = []; if(this.props.pagination){ - result = this.store.page(this.props.options.page || 1, - this.props.options.sizePerPage || Const.SIZE_PER_PAGE_LIST[0]) - .get(); + let page, sizePerPage; + if(this.store.isChangedPage()){ + sizePerPage = this.refs.pagination.getSizePerPage(); + page = this.refs.pagination.getCurrentPage(); + } else { + sizePerPage = this.props.options.sizePerPage || Const.SIZE_PER_PAGE_LIST[0]; + page = this.props.options.page || 1; + } + result = this.store.page(page, sizePerPage).get(); } else{ result = this.store.get(); } diff --git a/src/store/TableDataStore.js b/src/store/TableDataStore.js index 44e440f06..4b36bb6ea 100644 --- a/src/store/TableDataStore.js +++ b/src/store/TableDataStore.js @@ -221,6 +221,10 @@ export class TableDataStore{ return this.getCurrentDisplayData().length; } + isChangedPage(){ + return this.pageObj.start && this.pageObj.end ? true: false; + } + getAllRowkey(){ return this.data.map(function(row){ return row[this.keyField];