Skip to content

Commit 38fe46f

Browse files
feat: fixed header option
1 parent b4e12f2 commit 38fe46f

File tree

5 files changed

+32
-3
lines changed

5 files changed

+32
-3
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ const TableTd = styled.td<{
275275
border-color: ${(props) => props.$style.border} !important;
276276
border-width: ${(props) => props.$style.borderWidth} !important;
277277
border-radius: ${(props) => props.$style.radius};
278+
padding: 0 !important;
278279
279280
> div > div {
280281
color: ${(props) => props.$style.text};
@@ -362,6 +363,8 @@ type CustomTableProps<RecordType> = Omit<TableProps<RecordType>, "components" |
362363
viewModeResizable: boolean;
363364
rowColorFn: RowColorViewType;
364365
columnsStyle: TableColumnStyleType;
366+
fixedHeader: boolean;
367+
maxHeight: string;
365368
};
366369

367370
function TableCellView(props: {
@@ -533,7 +536,10 @@ function ResizeableTable<RecordType extends object>(props: CustomTableProps<Reco
533536
{...props}
534537
pagination={false}
535538
columns={columns}
536-
scroll={{ x: COL_MIN_WIDTH * columns.length }}
539+
scroll={{
540+
x: COL_MIN_WIDTH * columns.length,
541+
y: props.fixedHeader ? props.maxHeight : undefined,
542+
}}
537543
></Table>
538544
);
539545
}
@@ -690,6 +696,8 @@ export function TableCompView(props: {
690696
onTableChange(pagination, filters, sorter, extra, comp.dispatch, onEvent);
691697
}}
692698
showHeader={!compChildren.hideHeader.getView()}
699+
fixedHeader={compChildren.fixedHeader.getView()}
700+
maxHeight={compChildren.maxHeight.getView()}
693701
columns={antdColumns}
694702
columnsStyle={columnsStyle}
695703
viewModeResizable={compChildren.viewModeResizable.getView()}

client/packages/lowcoder/src/comps/comps/tableComp/tablePropertyView.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,12 +455,22 @@ export function compTablePropertyView<T extends MultiBaseComp<TableChildrenType>
455455
label: trans("table.tableSize"),
456456
radioButton: true,
457457
})}
458+
{comp.children.hideBordered.propertyView({
459+
label: trans("table.hideBordered"),
460+
})}
458461
{comp.children.hideHeader.propertyView({
459462
label: trans("table.hideHeader"),
460463
})}
461-
{comp.children.hideBordered.propertyView({
462-
label: trans("table.hideBordered"),
464+
{comp.children.fixedHeader.propertyView({
465+
label: trans("table.fixedHeader"),
466+
tooltip: trans("table.fixedHeaderTooltip")
463467
})}
468+
{comp.children.fixedHeader.getView() &&
469+
comp.children.maxHeight.propertyView({
470+
label: trans("table.maxHeight"),
471+
tooltip: trans("table.maxHeightTooltip")
472+
})
473+
}
464474
</Section>
465475
<Section name={"Row Style"}>
466476
{comp.children.rowStyle.getPropertyView()}

client/packages/lowcoder/src/comps/comps/tableComp/tableTypes.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
BoolCodeControl,
77
ColorOrBoolCodeControl,
88
JSONObjectArrayControl,
9+
RadiusControl,
910
} from "comps/controls/codeControl";
1011
import { dropdownControl } from "comps/controls/dropdownControl";
1112
import { eventHandlerControl } from "comps/controls/eventHandlerControl";
@@ -134,6 +135,8 @@ export type RowColorViewType = (param: {
134135
const tableChildrenMap = {
135136
hideBordered: BoolControl,
136137
hideHeader: BoolControl,
138+
fixedHeader: BoolControl,
139+
maxHeight: withDefault(RadiusControl, '300px'),
137140
data: withIsLoadingMethod(JSONObjectArrayControl),
138141
showDataLoadSpinner: withDefault(BoolPureControl, true),
139142
columns: ColumnListComp,

client/packages/lowcoder/src/i18n/locales/en.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,6 +1248,10 @@ export const en = {
12481248
type: "Type",
12491249
tableSize: "Table size",
12501250
hideHeader: "Hide table header",
1251+
fixedHeader: "Fixed table header",
1252+
fixedHeaderTooltip: "Header will be fixed for vertically scrollable table",
1253+
maxHeight: "Max. Height",
1254+
maxHeightTooltip: "Set max. height to make table scrollable",
12511255
hideBordered: "Hide column border",
12521256
deleteColumn: "Delete column",
12531257
confirmDeleteColumn: "Confirm delete column: ",

client/packages/lowcoder/src/i18n/locales/zh.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,10 @@ table: {
11741174
type: "类型",
11751175
tableSize: "表格尺寸",
11761176
hideHeader: "隐藏表头",
1177+
fixedHeader: "固定表头",
1178+
fixedHeaderTooltip: "垂直滚动表格的标题将被固定",
1179+
maxHeight: "最大限度。高度",
1180+
maxHeightTooltip: "设置最大值使表格可滚动的高度",
11771181
hideBordered: "隐藏列边框",
11781182
deleteColumn: "删除列",
11791183
confirmDeleteColumn: "确认删除列:",

0 commit comments

Comments
 (0)