ant-design/components/table/demo/paging.md

57 lines
920 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 5
2016-08-15 07:54:01 +08:00
title:
en-US: pagination
zh-CN: 分页
2016-03-31 09:40:55 +08:00
---
2015-07-09 20:29:26 +08:00
2016-08-15 08:07:03 +08:00
## zh-CN
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
数据项较多时显示分页。
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
## en-US
2016-08-15 07:54:01 +08:00
2016-08-15 08:07:03 +08:00
when use pagination in table.
2015-07-09 20:29:26 +08:00
````jsx
import { Table } from 'antd';
const columns = [{
title: '姓名',
2015-07-15 10:47:47 +08:00
dataIndex: 'name',
render(text) {
return <a href="#">{text}</a>;
2016-05-11 09:32:33 +08:00
},
}, {
title: '年龄',
2016-05-11 09:32:33 +08:00
dataIndex: 'age',
}, {
title: '住址',
2016-05-11 09:32:33 +08:00
dataIndex: 'address',
}];
const data = [];
for (let i = 0; i < 46; i++) {
data.push({
2015-08-28 15:22:09 +08:00
key: i,
name: `李大嘴${i}`,
age: 32,
2016-05-11 09:32:33 +08:00
address: `西湖区湖底公园${i}号`,
});
}
const pagination = {
total: data.length,
2015-12-24 10:12:31 +08:00
showSizeChanger: true,
onShowSizeChange(current, pageSize) {
2015-12-24 10:12:31 +08:00
console.log('Current: ', current, '; PageSize: ', pageSize);
},
onChange(current) {
console.log('Current: ', current);
2016-05-03 14:15:29 +08:00
},
};
2015-10-20 16:47:55 +08:00
ReactDOM.render(<Table columns={columns} dataSource={data} pagination={pagination} />
, mountNode);
2015-07-09 20:29:26 +08:00
````