-
-
Notifications
You must be signed in to change notification settings - Fork 619
Expand file tree
/
Copy pathexpandedSticky.tsx
More file actions
57 lines (53 loc) · 1.59 KB
/
expandedSticky.tsx
File metadata and controls
57 lines (53 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState } from 'react';
import type { ColumnType } from 'rc-table';
import Table from 'rc-table';
import '../../assets/index.less';
const Demo = () => {
const [expandedRowKeys, setExpandedRowKeys] = useState<readonly React.Key[]>([]);
const columns: ColumnType<Record<string, any>>[] = [
// { title: '分割', dataIndex: 'ca' },
{
title: '手机号',
dataIndex: 'a',
width: 100,
fixed: 'left',
onCell: (_, index) => {
const props: React.TdHTMLAttributes<HTMLTableCellElement> = {};
if (index === 0) props.rowSpan = 1;
if (index === 1) props.rowSpan = 2;
if (index === 2) props.rowSpan = 0;
return props;
},
},
Table.EXPAND_COLUMN,
{ title: 'Name', dataIndex: 'c' },
{ title: 'Address', fixed: 'right', dataIndex: 'd', width: 200 },
];
return (
<div
style={{
height: 10000,
}}
>
<h2>expanded & sticky</h2>
<Table<Record<string, any>>
rowKey="key"
sticky
scroll={{ x: 800 }}
columns={columns}
data={[
{ key: 'a', a: '12313132132', c: '小二', d: '文零西路' },
{ key: 'b', a: '13812340987', c: '张三', d: '文一西路' },
{ key: 'c', a: '13812340987', c: '张夫', d: '文二西路' },
]}
expandable={{
expandedRowKeys,
onExpandedRowsChange: keys => setExpandedRowKeys(keys),
expandedRowRender: record => <p style={{ margin: 0 }}>{record.key}</p>,
}}
className="table"
/>
</div>
);
};
export default Demo;