Skip to content

Commit 5a28671

Browse files
show/hide column title in table
1 parent cc9af45 commit 5a28671

File tree

6 files changed

+22
-4
lines changed

6 files changed

+22
-4
lines changed

client/packages/lowcoder/src/comps/comps/tableComp/column/tableColumnComp.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import { ColorControl } from "comps/controls/colorControl";
2727
import { JSONValue } from "util/jsonTypes";
2828
import styled from "styled-components";
2929
import { TextOverflowControl } from "comps/controls/textOverflowControl";
30-
import { TableColumnLinkStyle, styleControl } from "@lowcoder-ee/index.sdk";
3130
import { default as Divider } from "antd/es/divider";
3231
export type Render = ReturnType<ConstructorToComp<typeof RenderComp>["getOriginalComp"]>;
3332
export const RenderComp = withSelectedMultiContext(ColumnTypeComp);
@@ -86,6 +85,7 @@ export type CellColorViewType = (param: {
8685
export const columnChildrenMap = {
8786
// column title
8887
title: StringControl,
88+
showTitle: withDefault(BoolControl, true),
8989
// a custom column or a data column
9090
isCustom: valueComp<boolean>(false),
9191
// If it is a data column, it must be the name of the column and cannot be duplicated as a react key
@@ -149,6 +149,13 @@ export class ColumnComp extends ColumnInitComp {
149149
)
150150
);
151151
}
152+
if(action.type === CompActionTypes.CHANGE_VALUE) {
153+
const title = comp.children.title.unevaledValue;
154+
const dataIndex = comp.children.dataIndex.getView();
155+
if(!Boolean(title)) {
156+
comp.children.title.dispatchChangeValueAction(dataIndex);
157+
}
158+
}
152159
return comp;
153160
}
154161

@@ -180,9 +187,14 @@ export class ColumnComp extends ColumnInitComp {
180187
<>
181188
{this.children.title.propertyView({
182189
label: trans("table.columnTitle"),
190+
placeholder: this.children.dataIndex.getView(),
183191
})}
184192
{/* FIXME: cast type currently, return type of withContext should be corrected later */}
185193
{this.children.render.getPropertyView()}
194+
{this.children.showTitle.propertyView({
195+
label: trans("table.showTitle"),
196+
tooltip: trans("table.showTitleTooltip"),
197+
})}
186198
{ColumnTypeCompMap[columnType].canBeEditable() &&
187199
this.children.editable.propertyView({ label: trans("table.editable") })}
188200
{this.children.sortable.propertyView({
@@ -311,6 +323,7 @@ export function newPrimaryColumn(
311323
title?: string,
312324
isTag?: boolean
313325
): ConstructorToDataType<typeof ColumnComp> {
326+
console.log('newPrimaryColumn', title);
314327
return {
315328
title: title ?? key,
316329
dataIndex: key,

client/packages/lowcoder/src/comps/comps/tableComp/column/tableColumnListComp.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export class ColumnListComp extends ColumnListTmpComp {
101101
dynamicColumn: boolean;
102102
data: Array<JSONObject>;
103103
}) {
104-
console.log("dataChangedAction", param);
105104
return customAction<ActionDataType>(
106105
{
107106
type: "dataChanged",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ export function columnsToAntdFormat(
311311
}[];
312312
const title = renderTitle({ title: column.title, editable: column.editable });
313313
return {
314-
title: title,
314+
title: column.showTitle ? title : '',
315315
titleText: column.title,
316316
dataIndex: column.dataIndex,
317317
align: column.align,

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,9 @@ export const de = {
11241124
"columnValueTooltip": "\\'{{currentCell}}\\': Aktuelle Zelldaten\n \\'{{currentRow}}\\': Aktuelle Zeilendaten\n \\'{{currentIndex}}\\': Aktueller Datenindex (beginnend bei 0)\n Beispiel: \\'{{currentCell * 5}}\\' Show 5 Times the Original Value Data.",
11251125
"imageSrc": "Bildquelle",
11261126
"imageSize": "Bildgröße",
1127-
"columnTitle": "Titel",
1127+
"columnTitle": "Titel anzeigen",
1128+
"showTitle": "Show Title",
1129+
"showTitleTooltip": "Spaltentitel im Tabellenkopf ein-/ausblenden",
11281130
"sortable": "Sortierbar",
11291131
"align": "Ausrichtung",
11301132
"fixedColumn": "Feste Säule",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,6 +1229,8 @@ export const en = {
12291229
"imageSrc": "Image Source",
12301230
"imageSize": "Image Size",
12311231
"columnTitle": "Title",
1232+
"showTitle": "Show Title",
1233+
"showTitleTooltip": "Show/Hide column title in table header",
12321234
"sortable": "Sortable",
12331235
"align": "Alignment",
12341236
"fixedColumn": "Fixed Column",

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,6 +1200,8 @@ table: {
12001200
imageSrc: "图片链接",
12011201
imageSize: "图片尺寸",
12021202
columnTitle: "标题",
1203+
showTitle: "显示标题",
1204+
showTitleTooltip: "显示/隐藏表标题中的列标题",
12031205
sortable: "可排序",
12041206
align: "对齐方式",
12051207
fixedColumn: "固定列",

0 commit comments

Comments
 (0)