2016-03-31 09:40:55 +08:00
|
|
|
---
|
2016-11-22 10:11:12 +08:00
|
|
|
order: 17
|
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
|
|
|
|
2019-01-02 17:02:23 +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
|
|
|
|
2019-01-02 17:02:23 +08:00
|
|
|
> Specify width of columns if header and cell do not align properly. (Leave one column at least without width to fit fluid layout)
|
2016-03-06 22:44:58 +08:00
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2016-01-24 15:39:34 +08:00
|
|
|
import { Table } from 'antd';
|
|
|
|
|
|
|
|
const columns = [{
|
2016-10-02 08:47:42 +08:00
|
|
|
title: 'Name',
|
2016-01-24 15:39:34 +08:00
|
|
|
dataIndex: 'name',
|
|
|
|
width: 150,
|
|
|
|
}, {
|
2016-10-02 08:47:42 +08:00
|
|
|
title: 'Age',
|
2016-01-24 15:39:34 +08:00
|
|
|
dataIndex: 'age',
|
|
|
|
width: 150,
|
|
|
|
}, {
|
2016-10-02 08:47:42 +08:00
|
|
|
title: 'Address',
|
2016-01-24 15:39:34 +08:00
|
|
|
dataIndex: 'address',
|
|
|
|
}];
|
|
|
|
|
|
|
|
const data = [];
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
|
|
data.push({
|
|
|
|
key: i,
|
2016-10-02 08:47:42 +08:00
|
|
|
name: `Edward King ${i}`,
|
2016-01-24 15:39:34 +08:00
|
|
|
age: 32,
|
2016-10-02 08:47:42 +08:00
|
|
|
address: `London, Park Lane no. ${i}`,
|
2016-01-24 15:39:34 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(
|
2018-06-27 15:55:04 +08:00
|
|
|
<Table columns={columns} dataSource={data} pagination={{ pageSize: 50 }} scroll={{ y: 240 }} />,
|
2018-11-28 15:00:03 +08:00
|
|
|
mountNode
|
|
|
|
);
|
2016-01-24 15:39:34 +08:00
|
|
|
````
|