diff --git a/components/table/demo/paging.md b/components/table/demo/paging.md index 9e3917f53b..2459cae6d9 100644 --- a/components/table/demo/paging.md +++ b/components/table/demo/paging.md @@ -39,6 +39,9 @@ const pagination = { showSizeChanger: true, onShowSizeChange: function(current, pageSize) { console.log('Current: ', current, '; PageSize: ', pageSize); + }, + onChange: function(current) { + console.log('Current: ', current); } }; diff --git a/components/table/index.jsx b/components/table/index.jsx index c2c0e73049..b0ca7a8314 100644 --- a/components/table/index.jsx +++ b/components/table/index.jsx @@ -19,6 +19,13 @@ const defaultLocale = { emptyText: '暂无数据', }; +const defaultPagination = { + pageSize: 10, + current: 1, + onChange: noop, + onShowSizeChange: noop, +}; + let AntTable = React.createClass({ getInitialState() { return { @@ -30,10 +37,9 @@ let AntTable = React.createClass({ sortOrder: '', sorter: null, radioIndex: null, - pagination: this.hasPagination() ? objectAssign({ - pageSize: 10, - current: 1 - }, this.props.pagination) : {} + pagination: this.hasPagination() ? + objectAssign({}, defaultPagination, this.props.pagination) : + {}, }; }, @@ -253,6 +259,8 @@ let AntTable = React.createClass({ } else { pagination.current = pagination.current || 1; } + pagination.onChange(pagination.current); + const newState = { selectionDirty: false, pagination @@ -423,9 +431,7 @@ let AntTable = React.createClass({ handleShowSizeChange(current, pageSize) { const pagination = this.state.pagination; - if (pagination.onShowSizeChange) { - pagination.onShowSizeChange(current, pageSize); - } + pagination.onShowSizeChange(current, pageSize); let nextPagination = objectAssign(pagination, { pageSize: pageSize