mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 04:58:55 +08:00
Refactor node pagination code, Add noPagination demo
This commit is contained in:
parent
deb00174aa
commit
b7d204967d
38
components/table/demo/nopagination.md
Normal file
38
components/table/demo/nopagination.md
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# 不显示分页
|
||||||
|
|
||||||
|
- order: 8
|
||||||
|
|
||||||
|
传入 pagination 为 false 即可。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
````jsx
|
||||||
|
var Table = antd.Table;
|
||||||
|
var columns = [{
|
||||||
|
title: '姓名',
|
||||||
|
dataIndex: 'name'
|
||||||
|
}, {
|
||||||
|
title: '年龄',
|
||||||
|
dataIndex: 'age'
|
||||||
|
}, {
|
||||||
|
title: '住址',
|
||||||
|
dataIndex: 'address'
|
||||||
|
}];
|
||||||
|
|
||||||
|
var data = [{
|
||||||
|
name: '胡彦斌',
|
||||||
|
age: 32,
|
||||||
|
address: '西湖区湖底公园1号'
|
||||||
|
}, {
|
||||||
|
name: '胡彦祖',
|
||||||
|
age: 42,
|
||||||
|
address: '西湖区湖底公园1号'
|
||||||
|
}, {
|
||||||
|
name: '李大嘴',
|
||||||
|
age: 32,
|
||||||
|
address: '西湖区湖底公园1号'
|
||||||
|
}];
|
||||||
|
|
||||||
|
React.render(<Table columns={columns} dataSource={data} pagination={false} />
|
||||||
|
, document.getElementById('components-table-demo-nopagination'));
|
||||||
|
````
|
@ -24,19 +24,18 @@ export default React.createClass({
|
|||||||
getPagination: function() {}
|
getPagination: function() {}
|
||||||
}, this.props.dataSource);
|
}, this.props.dataSource);
|
||||||
}
|
}
|
||||||
let pagination;
|
|
||||||
if (this.props.pagination === false) {
|
let noPagination = (this.props.pagination === false);
|
||||||
pagination = false;
|
let pagination = objectAssign({
|
||||||
} else {
|
|
||||||
pagination = objectAssign({
|
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
total: this.props.dataSource.length
|
total: this.props.dataSource.length
|
||||||
}, this.props.pagination);
|
}, this.props.pagination);
|
||||||
}
|
|
||||||
return {
|
return {
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
loading: false,
|
loading: false,
|
||||||
pagination: pagination,
|
pagination: pagination,
|
||||||
|
noPagination: noPagination,
|
||||||
data: []
|
data: []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@ -137,9 +136,9 @@ export default React.createClass({
|
|||||||
this.props.rowSelection.onSelectAll(checked, selectedRows);
|
this.props.rowSelection.onSelectAll(checked, selectedRows);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handlePageChange: function(current) {
|
handlePageChange(current = 1) {
|
||||||
let pagination = this.state.pagination || {};
|
let pagination = this.state.pagination || {};
|
||||||
pagination.current = current || 1;
|
pagination.current = current;
|
||||||
this.setState({
|
this.setState({
|
||||||
pagination: pagination
|
pagination: pagination
|
||||||
}, this.fetch);
|
}, this.fetch);
|
||||||
@ -218,7 +217,7 @@ export default React.createClass({
|
|||||||
},
|
},
|
||||||
renderPagination() {
|
renderPagination() {
|
||||||
// 强制不需要分页
|
// 强制不需要分页
|
||||||
if (this.props.pagination === false) {
|
if (this.state.noPagination) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
let classString = 'ant-table-pagination';
|
let classString = 'ant-table-pagination';
|
||||||
@ -283,7 +282,7 @@ export default React.createClass({
|
|||||||
let data = this.props.dataSource;
|
let data = this.props.dataSource;
|
||||||
let current, pageSize;
|
let current, pageSize;
|
||||||
// 如果没有分页的话,默认全部展示
|
// 如果没有分页的话,默认全部展示
|
||||||
if (this.props.pagination === false) {
|
if (this.state.noPagination) {
|
||||||
pageSize = Number.MAX_VALUE;
|
pageSize = Number.MAX_VALUE;
|
||||||
current = 1;
|
current = 1;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user