Skip to content

Commit 6f5f5c5

Browse files
committed
Add footer/ header customizations + virtualization layout fix
1 parent 8a4c68f commit 6f5f5c5

File tree

5 files changed

+53
-20
lines changed

5 files changed

+53
-20
lines changed

client/packages/lowcoder/src/comps/comps/tableLiteComp/hooks/useTableConfiguration.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ interface HeightConfig {
4646
toolbarHeight?: number;
4747
headerHeight?: number;
4848
containerPadding?: number;
49+
stickyToolbar?: boolean; // when true, toolbar is outside scroll and should be reserved
4950
}
5051

5152
export function useTableHeights(
@@ -74,20 +75,18 @@ export function useTableHeights(
7475
showHeader = true,
7576
toolbarHeight = 48,
7677
headerHeight = 40,
77-
containerPadding = 0
78+
containerPadding = 0,
79+
stickyToolbar = false,
7880
} = config;
7981

80-
const toolbarSpace = showToolbar ? toolbarHeight : 0;
82+
// Reserve space for toolbar ONLY if it's sticky (outside the scroll area)
83+
const toolbarSpace = showToolbar && stickyToolbar ? toolbarHeight : 0;
8184
const headerSpace = showHeader ? headerHeight : 0;
8285
const totalUsedSpace = toolbarSpace + headerSpace + containerPadding;
8386

8487
// Calculate available height for table body
8588
const bodyHeight = Math.max(0, containerHeight - totalUsedSpace);
8689

87-
console.log('Container height:', containerHeight);
88-
console.log('Body height calculated:', bodyHeight);
89-
90-
9190
return {
9291
containerStyle: {
9392
height: '100%',

client/packages/lowcoder/src/comps/comps/tableLiteComp/parts/TableContainer.tsx

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,37 @@ export const TableContainer: React.FC<TableContainerProps> = ({
6161
}) => {
6262
const ToolbarComponent = stickyToolbar ? StickyToolbar : DefaultToolbar;
6363

64+
const renderToolbarOutside = stickyToolbar && showToolbar;
65+
const renderToolbarInside = !stickyToolbar && showToolbar;
66+
6467
return (
6568
<MainContainer $mode={mode} $height={containerHeight} ref={containerRef}>
66-
{/* Above toolbar */}
67-
{showToolbar && toolbarPosition === 'above' && (
69+
{/* Above toolbar (sticky) */}
70+
{renderToolbarOutside && toolbarPosition === 'above' && (
6871
<ToolbarComponent $position="above">
6972
{toolbar}
7073
</ToolbarComponent>
7174
)}
7275

73-
{/* Table content */}
76+
{/* Table content + optional non-sticky toolbar inside scrollable area */}
7477
<TableSection $mode={mode}>
78+
{/* Non-sticky toolbar ABOVE inside scrollable area */}
79+
{renderToolbarInside && toolbarPosition === 'above' && (
80+
<DefaultToolbar>
81+
{toolbar}
82+
</DefaultToolbar>
83+
)}
7584
{children}
85+
{/* Non-sticky toolbar BELOW inside scrollable area */}
86+
{renderToolbarInside && toolbarPosition === 'below' && (
87+
<DefaultToolbar>
88+
{toolbar}
89+
</DefaultToolbar>
90+
)}
7691
</TableSection>
7792

78-
{/* Below toolbar */}
79-
{showToolbar && toolbarPosition === 'below' && (
93+
{/* Below toolbar (sticky) */}
94+
{renderToolbarOutside && toolbarPosition === 'below' && (
8095
<ToolbarComponent $position="below">
8196
{toolbar}
8297
</ToolbarComponent>

client/packages/lowcoder/src/comps/comps/tableLiteComp/parts/TableRenderer.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,10 @@ function TableRendererComp<RecordType extends object>(props: TableRendererProps<
9191
);
9292
}
9393

94-
const scrollConfig = { x: totalWidth, y: bodyHeight };
95-
9694
// VIRTUALIZED: High performance for large datasets
9795
if (virtualizationConfig.enabled && heights.canVirtualize) {
98-
console.log('VirtualizedTable');
96+
console.log('VirtualizedTable');
97+
const scrollConfig = { x: totalWidth, y: bodyHeight };
9998
return (
10099
<VirtualizedTable
101100
{...baseTableProps}
@@ -116,13 +115,14 @@ function TableRendererComp<RecordType extends object>(props: TableRendererProps<
116115
);
117116
}
118117

119-
// FIXED: Regular height-constrained mode
118+
// FIXED: Regular height-constrained mode without internal vertical scroll
119+
// Let the outer container handle vertical scrolling so the footer appears right after the table
120120
return (
121121
<FixedModeTable
122122
{...baseTableProps}
123123
columns={columns}
124124
bodyHeight={bodyHeight}
125-
scroll={scrollConfig}
125+
scroll={{ x: totalWidth }}
126126
virtual={false}
127127
style={props.style}
128128
headerStyle={props.headerStyle}

client/packages/lowcoder/src/comps/comps/tableLiteComp/styles/TableContainerStyles.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ export const TableContainer = styled.div<{
1111
font-size: 12px; /* Smaller font */
1212
line-height: 1.4;
1313
}
14+
/* Virtualized body cell padding */
15+
.ant-table-tbody-virtual .ant-table-cell {
16+
padding: 8px 8px !important;
17+
font-size: 12px;
18+
line-height: 1.4;
19+
}
1420
1521
/* Header cell padding and font */
1622
.ant-table-thead > tr > th {
@@ -33,6 +39,12 @@ export const TableContainer = styled.div<{
3339
font-size: 14px;
3440
line-height: 1.5;
3541
}
42+
/* Virtualized body cell padding */
43+
.ant-table-tbody-virtual .ant-table-cell {
44+
padding: 12px 12px !important;
45+
font-size: 14px;
46+
line-height: 1.5;
47+
}
3648
3749
/* Header cell padding and font */
3850
.ant-table-thead > tr > th {
@@ -54,6 +66,12 @@ export const TableContainer = styled.div<{
5466
font-size: 14px;
5567
line-height: 1.6;
5668
}
69+
/* Virtualized body cell padding */
70+
.ant-table-tbody-virtual .ant-table-cell {
71+
padding: 16px 16px !important;
72+
font-size: 14px;
73+
line-height: 1.6;
74+
}
5775
5876
/* Header cell padding and font */
5977
.ant-table-thead > tr > th {

client/packages/lowcoder/src/comps/comps/tableLiteComp/tableCompView.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const TableCompView = React.memo((props: {
4949
const autoHeight = compChildren.autoHeight.getView();
5050
const rowAutoHeight = compChildren.rowAutoHeight.getView();
5151
const showHeader = !compChildren.hideHeader.getView();
52-
const stickyToolbar = false; // TODO: Add this as a prop later
52+
const stickyToolbar = !!toolbar.fixedToolbar; // use toolbar setting
5353

5454

5555
// NEW: Use hooks for clean logic
@@ -59,7 +59,8 @@ export const TableCompView = React.memo((props: {
5959
showToolbar: !hideToolbar,
6060
showHeader: showHeader,
6161
toolbarHeight: 48,
62-
headerHeight: 40
62+
headerHeight: 40,
63+
stickyToolbar,
6364
});
6465
const virtualization = useVirtualization(
6566
heights.canVirtualize,
@@ -74,8 +75,8 @@ export const TableCompView = React.memo((props: {
7475
);
7576
const columnsAggrData = comp.columnAggrData;
7677
const headerFilters = useMemo(() => compChildren.headerFilters.getView(), [compChildren.headerFilters]);
77-
78-
78+
79+
7980

8081
const antdColumns = useMemo(
8182
() =>

0 commit comments

Comments
 (0)