@@ -6,6 +6,7 @@ import type { FlattenData } from '../hooks/useFlattenRecords';
6
6
import { StaticContext } from './context' ;
7
7
import VirtualCell from './VirtualCell' ;
8
8
import useRowInfo from '../hooks/useRowInfo' ;
9
+ import Cell from '../Cell' ;
9
10
10
11
export interface BodyLineProps < RecordType = any > {
11
12
data : FlattenData < RecordType > ;
@@ -23,11 +24,11 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
23
24
const { data, index, className, rowKey, style, extra, getHeight, ...restProps } = props ;
24
25
const { record, indent } = data ;
25
26
26
- const { flattenColumns, prefixCls } = useContext ( TableContext , [
27
+ const { flattenColumns, prefixCls, fixColumn , componentWidth } = useContext ( TableContext , [
27
28
'prefixCls' ,
28
29
'flattenColumns' ,
29
- 'expandableType ' ,
30
- 'rowExpandable ' ,
30
+ 'fixColumn ' ,
31
+ 'componentWidth ' ,
31
32
] ) ;
32
33
const { scrollX } = useContext ( StaticContext , [ 'scrollX' ] ) ;
33
34
@@ -41,6 +42,20 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
41
42
const expandContent = expandedRowRender ( record , index , indent + 1 , expanded ) ;
42
43
const computedExpandedRowClassName = expandedRowClassName ?.( record , index , indent ) ;
43
44
45
+ let additionalProps : React . TdHTMLAttributes < HTMLElement > = { } ;
46
+ if ( fixColumn ) {
47
+ additionalProps = {
48
+ style : {
49
+ position : 'sticky' ,
50
+ left : 0 ,
51
+ overflow : 'hidden' ,
52
+ [ '--virtual-width' as any ] : `${ componentWidth } px` ,
53
+ } ,
54
+ } ;
55
+ }
56
+
57
+ const rowCellCls = `${ prefixCls } -expanded-row-cell` ;
58
+
44
59
expandRowNode = (
45
60
< div
46
61
className = { classNames (
@@ -49,7 +64,16 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
49
64
computedExpandedRowClassName ,
50
65
) }
51
66
>
52
- { expandContent }
67
+ < Cell
68
+ component = "div"
69
+ prefixCls = { prefixCls }
70
+ className = { classNames ( rowCellCls , {
71
+ [ `${ rowCellCls } -fixed` ] : fixColumn ,
72
+ } ) }
73
+ additionalProps = { additionalProps }
74
+ >
75
+ { expandContent }
76
+ </ Cell >
53
77
</ div >
54
78
) ;
55
79
}
0 commit comments