2019-09-03 18:47:17 +08:00
|
|
|
---
|
2019-11-15 14:35:25 +08:00
|
|
|
order: 28
|
2019-09-03 18:47:17 +08:00
|
|
|
title:
|
|
|
|
en-US: ellipsis column
|
|
|
|
zh-CN: 单元格自动省略
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
设置 `column.ellipsis` 可以让单元格内容根据宽度自动省略。
|
|
|
|
|
2019-09-04 11:20:53 +08:00
|
|
|
> 列头缩略暂不支持和排序筛选一起使用。
|
|
|
|
|
2019-09-03 18:47:17 +08:00
|
|
|
## en-US
|
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
Ellipsis cell content via setting `column.ellipsis`.
|
2019-09-03 18:47:17 +08:00
|
|
|
|
2019-11-15 14:35:25 +08:00
|
|
|
> Cannot ellipsis table header with sorters and filters for now.
|
2019-09-04 11:20:53 +08:00
|
|
|
|
2019-09-03 18:47:17 +08:00
|
|
|
```jsx
|
2019-09-03 19:00:14 +08:00
|
|
|
import { Table } from 'antd';
|
2019-09-03 18:47:17 +08:00
|
|
|
|
|
|
|
const columns = [
|
|
|
|
{
|
|
|
|
title: 'Name',
|
|
|
|
dataIndex: 'name',
|
|
|
|
key: 'name',
|
|
|
|
render: text => <a>{text}</a>,
|
|
|
|
width: 150,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Age',
|
|
|
|
dataIndex: 'age',
|
|
|
|
key: 'age',
|
|
|
|
width: 80,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Address',
|
|
|
|
dataIndex: 'address',
|
|
|
|
key: 'address 1',
|
|
|
|
ellipsis: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Long Column Long Column Long Column',
|
|
|
|
dataIndex: 'address',
|
|
|
|
key: 'address 2',
|
|
|
|
ellipsis: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Long Column Long Column',
|
|
|
|
dataIndex: 'address',
|
|
|
|
key: 'address 3',
|
|
|
|
ellipsis: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
title: 'Long Column',
|
|
|
|
dataIndex: 'address',
|
|
|
|
key: 'address 4',
|
|
|
|
ellipsis: true,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const data = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
name: 'John Brown',
|
|
|
|
age: 32,
|
|
|
|
address: 'New York No. 1 Lake Park, New York No. 1 Lake Park',
|
|
|
|
tags: ['nice', 'developer'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
name: 'Jim Green',
|
|
|
|
age: 42,
|
|
|
|
address: 'London No. 2 Lake Park, London No. 2 Lake Park',
|
|
|
|
tags: ['loser'],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
name: 'Joe Black',
|
|
|
|
age: 32,
|
|
|
|
address: 'Sidney No. 1 Lake Park, Sidney No. 1 Lake Park',
|
|
|
|
tags: ['cool', 'teacher'],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
ReactDOM.render(<Table columns={columns} dataSource={data} />, mountNode);
|
|
|
|
```
|