Merge pull request #737 from ant-design/feat-table

feat: expose `onShowSizeChange`
This commit is contained in:
afc163 2015-12-24 10:42:48 +08:00
commit 8c013e25f1
3 changed files with 16 additions and 8 deletions

View File

@ -36,7 +36,10 @@ for (let i = 0; i < 46; i++) {
const pagination = { const pagination = {
total: data.length, total: data.length,
current: 1, 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} /> ReactDOM.render(<Table columns={columns} dataSource={data} pagination={pagination} />

View File

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

View File

@ -91,7 +91,7 @@
"eslint-plugin-react": "^3.3.1", "eslint-plugin-react": "^3.3.1",
"extract-text-webpack-plugin": "^0.9.1", "extract-text-webpack-plugin": "^0.9.1",
"gh-pages": "^0.5.0", "gh-pages": "^0.5.0",
"history": "~1.13.1", "history": "^1.17.0",
"jest-cli": "~0.8.0", "jest-cli": "~0.8.0",
"json-loader": "^0.5.1", "json-loader": "^0.5.1",
"less": "~2.5.3", "less": "~2.5.3",
@ -104,7 +104,7 @@
"react-addons-test-utils": "~0.14.2", "react-addons-test-utils": "~0.14.2",
"react-copy-to-clipboard": "^3.0.4", "react-copy-to-clipboard": "^3.0.4",
"react-dom": "~0.14.2", "react-dom": "~0.14.2",
"react-router": "~1.0.0", "react-router": "~1.0.3",
"react-stateless-wrapper": "~1.0.2", "react-stateless-wrapper": "~1.0.2",
"reqwest": "~2.0.5", "reqwest": "~2.0.5",
"webpack": "^1.10.1", "webpack": "^1.10.1",