ant-design/components/table/demo/fixed-header.md

50 lines
865 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 16
2016-08-15 07:54:01 +08:00
title:
en-US: Fixed Header
zh-CN: 固定表头
2016-03-31 09:40:55 +08:00
---
2016-01-24 15:39:34 +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
需要指定 column 的 `width` 属性,否则列头和内容可能不对齐。
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
Display large amounts of data in scrollable view.
2016-01-24 15:39:34 +08:00
2016-08-15 08:07:03 +08:00
> Specify the width of each column if header and cell do not align properly.
2016-03-06 22:44:58 +08:00
2016-01-24 15:39:34 +08:00
````jsx
import { Table } from 'antd';
const columns = [{
title: '姓名',
dataIndex: 'name',
width: 150,
}, {
title: '年龄',
dataIndex: 'age',
width: 150,
}, {
title: '住址',
dataIndex: 'address',
}];
const data = [];
for (let i = 0; i < 100; i++) {
data.push({
key: i,
name: `李大嘴${i}`,
2016-01-24 15:39:34 +08:00
age: 32,
2016-05-11 09:32:33 +08:00
address: `西湖区湖底公园${i}号`,
2016-01-24 15:39:34 +08:00
});
}
ReactDOM.render(
2016-03-24 17:01:41 +08:00
<Table columns={columns} dataSource={data} pagination={{ pageSize: 50 }} scroll={{ y: 240 }} />
2016-01-24 15:39:34 +08:00
, mountNode);
````