feat: expose onShowSizeChange

This commit is contained in:
Benjy Cui 2015-12-24 10:12:31 +08:00
parent a84be2c043
commit 38083e5a9f
2 changed files with 14 additions and 6 deletions

View File

@ -36,7 +36,10 @@ for (let i = 0; i < 46; i++) {
const pagination = {
total: data.length,
current: 1,
showSizeChanger: true
showSizeChanger: true,
onShowSizeChange: function(current, pageSize) {
console.log('Current: ', current, '; PageSize: ', pageSize);
}
};
ReactDOM.render(<Table columns={columns} dataSource={data} pagination={pagination} />

View File

@ -410,10 +410,15 @@ let AntTable = React.createClass({
},
handleShowSizeChange(current, pageSize) {
let pagination = objectAssign(this.state.pagination, {
const pagination = this.state.pagination;
if (pagination.onShowSizeChange) {
pagination.onShowSizeChange(current, pageSize);
}
let nextPagination = objectAssign(pagination, {
pageSize: pageSize
});
this.setState({ pagination });
this.setState({ pagination: nextPagination });
},
renderPagination() {
@ -427,12 +432,12 @@ let AntTable = React.createClass({
});
let total = this.state.pagination.total || this.getLocalData().length;
return (total > 0) ?
<Pagination className={classString}
<Pagination {...this.state.pagination}
className={classString}
onChange={this.handlePageChange}
total={total}
pageSize={10}
onShowSizeChange={this.handleShowSizeChange}
{...this.state.pagination} /> : null;
onShowSizeChange={this.handleShowSizeChange} /> : null;
},
prepareParamsArguments(state) {