Skip to content

Commit 9d5e0aa

Browse files
committed
[Fix]: #1795 remove unnecessary code
1 parent 7c17a48 commit 9d5e0aa

File tree

2 files changed

+10
-58
lines changed

2 files changed

+10
-58
lines changed

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

Lines changed: 8 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -99,65 +99,16 @@ export class TableImplComp extends TableInitComp implements IContainer {
9999
}
100100

101101
downloadData(fileName: string) {
102-
const allDisplayData = (this as any).exposingValues["displayData"];
102+
// displayData already contains only visible columns (filtered in transformDispalyData)
103+
const displayData = (this as any).exposingValues["displayData"];
103104
const delimiter = this.children.toolbar.children.columnSeparator.getView();
104105

105-
try {
106-
// Build the set of visible column keys as shown to the user (title or dataIndex)
107-
const enableColumnSetting = this.children.toolbar.children.columnSetting.getView();
108-
const visibleColumnKeys = new Set<string>();
109-
this.children.columns.getView().forEach((col) => {
110-
const colView = col.getView();
111-
const isHidden = columnHide({
112-
hide: colView.hide,
113-
tempHide: colView.tempHide,
114-
enableColumnSetting,
115-
});
116-
if (!isHidden) {
117-
const headerKey = (colView.title as any) || colView.dataIndex;
118-
if (headerKey) {
119-
visibleColumnKeys.add(String(headerKey));
120-
}
121-
}
122-
});
123-
124-
const pickVisible = (row: any): any => {
125-
const result: any = {};
126-
// copy only allowed keys
127-
Object.keys(row || {}).forEach((key) => {
128-
if (key !== COLUMN_CHILDREN_KEY && visibleColumnKeys.has(key)) {
129-
result[key] = row[key];
130-
}
131-
});
132-
// retain children recursively if present
133-
if (Array.isArray(row?.[COLUMN_CHILDREN_KEY])) {
134-
const children = row[COLUMN_CHILDREN_KEY].map((r: any) => pickVisible(r));
135-
if (children.length) {
136-
result[COLUMN_CHILDREN_KEY] = children;
137-
}
138-
}
139-
return result;
140-
};
141-
142-
const dataToSave = Array.isArray(allDisplayData)
143-
? allDisplayData.map((r: any) => pickVisible(r))
144-
: allDisplayData;
145-
146-
saveDataAsFile({
147-
data: dataToSave,
148-
filename: fileName,
149-
fileType: "csv",
150-
delimiter,
151-
});
152-
} catch (_e) {
153-
// Fallback to previous behavior if anything goes wrong
154-
saveDataAsFile({
155-
data: allDisplayData,
156-
filename: fileName,
157-
fileType: "csv",
158-
delimiter,
159-
});
160-
}
106+
saveDataAsFile({
107+
data: displayData,
108+
filename: fileName,
109+
fileType: "csv",
110+
delimiter,
111+
});
161112
}
162113

163114
refreshData(allQueryNames: Array<string>, setLoading: (loading: boolean) => void) {

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ export function transformDispalyData(
209209
return oriDisplayData.map((row) => {
210210
const transData = _(row)
211211
.omit(OB_ROW_ORI_INDEX)
212-
.mapKeys((value, key) => dataIndexTitleDict[key] || key)
212+
.pickBy((value, key) => key in dataIndexTitleDict) // Only include columns in the dictionary
213+
.mapKeys((value, key) => dataIndexTitleDict[key])
213214
.value();
214215
if (Array.isArray(row[COLUMN_CHILDREN_KEY])) {
215216
return {

0 commit comments

Comments
 (0)