Skip to content

Commit da814ef

Browse files
committed
chore: nest of cell in row
1 parent dca77e3 commit da814ef

File tree

2 files changed

+34
-10
lines changed

2 files changed

+34
-10
lines changed

docs/examples/virtual.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function cleanOnCell(cols: any = []) {
167167
cleanOnCell((col as any).children);
168168
});
169169
}
170-
// cleanOnCell(columns);
170+
cleanOnCell(columns);
171171

172172
const data: RecordType[] = new Array(4 * 10000).fill(null).map((_, index) => ({
173173
a: `a${index}`,
@@ -201,11 +201,11 @@ const Demo = () => {
201201
scroll={{ x: 1200, y: scrollY ? 200 : null }}
202202
data={data}
203203
rowKey="indexKey"
204-
// expandable={{
205-
// expandedRowRender: () => 2333,
206-
// columnWidth: 60,
207-
// expandedRowClassName: () => 'good-one',
208-
// }}
204+
expandable={{
205+
expandedRowRender: () => 2333,
206+
columnWidth: 60,
207+
expandedRowClassName: () => 'good-one',
208+
}}
209209
// onRow={() => ({ className: 'rowed' })}
210210
rowClassName="nice-try"
211211
/>

src/VirtualTable/BodyLine.tsx

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import type { FlattenData } from '../hooks/useFlattenRecords';
66
import { StaticContext } from './context';
77
import VirtualCell from './VirtualCell';
88
import useRowInfo from '../hooks/useRowInfo';
9+
import Cell from '../Cell';
910

1011
export interface BodyLineProps<RecordType = any> {
1112
data: FlattenData<RecordType>;
@@ -23,11 +24,11 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
2324
const { data, index, className, rowKey, style, extra, getHeight, ...restProps } = props;
2425
const { record, indent } = data;
2526

26-
const { flattenColumns, prefixCls } = useContext(TableContext, [
27+
const { flattenColumns, prefixCls, fixColumn, componentWidth } = useContext(TableContext, [
2728
'prefixCls',
2829
'flattenColumns',
29-
'expandableType',
30-
'rowExpandable',
30+
'fixColumn',
31+
'componentWidth',
3132
]);
3233
const { scrollX } = useContext(StaticContext, ['scrollX']);
3334

@@ -41,6 +42,20 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
4142
const expandContent = expandedRowRender(record, index, indent + 1, expanded);
4243
const computedExpandedRowClassName = expandedRowClassName?.(record, index, indent);
4344

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+
4459
expandRowNode = (
4560
<div
4661
className={classNames(
@@ -49,7 +64,16 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
4964
computedExpandedRowClassName,
5065
)}
5166
>
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>
5377
</div>
5478
);
5579
}

0 commit comments

Comments
 (0)