Skip to content

Commit 6696f2e

Browse files
committed
feat(datagrid-web): wc-3441 export column enhancements
1 parent e769b71 commit 6696f2e

8 files changed

Lines changed: 269 additions & 59 deletions

File tree

packages/pluggableWidgets/datagrid-web/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,17 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Added
10+
11+
- We updated Export to Excel column configuration to support separate export behavior per column content type:
12+
- Attribute columns now support `Default` (use attribute formatter) and `Custom` export type with a shared `Export format` property.
13+
- Dynamic text columns always export as strings and no longer require export type or export format configuration.
14+
- Custom content columns use `Export value` together with export type (`String`, `Number`, `Date`, `Boolean`) and support `Export format` for number/date values.
15+
16+
### Changed
17+
18+
- We kept legacy export properties (`exportType`, `exportNumberFormat`, `exportDateFormat`) as runtime fallbacks for backward compatibility with existing widget configurations.
19+
920
## [3.11.1] - 2026-06-18
1021

1122
### Fixed

packages/pluggableWidgets/datagrid-web/src/Datagrid.editorConfig.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export function getProperties(values: DatagridPreviewProps, defaultProperties: P
3030
hideNestedPropertiesIn(defaultProperties, values, "columns", index, [
3131
"content",
3232
"allowEventPropagation",
33-
"exportValue"
33+
"exportValue",
34+
"customContentExportType"
3435
]);
3536
}
3637
if (column.showContentAs === "customContent") {
@@ -57,14 +58,28 @@ export function getProperties(values: DatagridPreviewProps, defaultProperties: P
5758
if (column.minWidth !== "manual") {
5859
hidePropertyIn(defaultProperties, values, "columns", index, "minWidthLimit");
5960
}
60-
// Hide exportNumberFormat if exportType is not 'number'
61-
if (column.exportType !== "number") {
62-
hidePropertyIn(defaultProperties, values, "columns", index, "exportNumberFormat" as any);
61+
// Hide new export controls by column content type.
62+
if (column.showContentAs !== "attribute") {
63+
hidePropertyIn(defaultProperties, values, "columns", index, "attributeExportType" as any);
6364
}
64-
// Hide exportDateFormat if exportType is not 'date'
65-
if (column.exportType !== "date") {
66-
hidePropertyIn(defaultProperties, values, "columns", index, "exportDateFormat" as any);
65+
if (column.showContentAs === "dynamicText") {
66+
hidePropertyIn(defaultProperties, values, "columns", index, "exportFormat" as any);
6767
}
68+
if (column.showContentAs === "attribute" && column.attributeExportType !== "custom") {
69+
hidePropertyIn(defaultProperties, values, "columns", index, "exportFormat" as any);
70+
}
71+
if (
72+
column.showContentAs === "customContent" &&
73+
column.customContentExportType !== "number" &&
74+
column.customContentExportType !== "date"
75+
) {
76+
hidePropertyIn(defaultProperties, values, "columns", index, "exportFormat" as any);
77+
}
78+
79+
// Hide legacy export controls in Studio Pro. They are still supported at runtime for backward compatibility.
80+
hidePropertyIn(defaultProperties, values, "columns", index, "exportType" as any);
81+
hidePropertyIn(defaultProperties, values, "columns", index, "exportNumberFormat" as any);
82+
hidePropertyIn(defaultProperties, values, "columns", index, "exportDateFormat" as any);
6883
});
6984

7085
if (values.pagination === "buttons") {
@@ -205,7 +220,10 @@ export const getPreview = (
205220
minWidth: "auto",
206221
minWidthLimit: 100,
207222
allowEventPropagation: true,
223+
attributeExportType: "default",
208224
exportValue: "",
225+
customContentExportType: "string",
226+
exportFormat: "",
209227
exportType: "default",
210228
exportDateFormat: "",
211229
exportNumberFormat: ""

packages/pluggableWidgets/datagrid-web/src/Datagrid.editorPreview.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import cn from "classnames";
44
import { GUID, ObjectItem } from "mendix";
55
import { Selectable } from "mendix/preview/Selectable";
66
import { createContext, CSSProperties, PropsWithChildren, ReactElement, ReactNode, useContext } from "react";
7-
import { ColumnsPreviewType, DatagridPreviewProps } from "typings/DatagridProps";
7+
import { ColumnsPreviewType, DatagridPreviewProps } from "../typings/DatagridProps";
88
import { FaArrowsAltV } from "./components/icons/FaArrowsAltV";
99
import { FaEye } from "./components/icons/FaEye";
1010
import { ColumnPreview } from "./helpers/ColumnPreview";
@@ -39,7 +39,10 @@ const defaultColumn: ColumnsPreviewType = {
3939
minWidth: "auto",
4040
minWidthLimit: 100,
4141
allowEventPropagation: true,
42+
attributeExportType: "default",
4243
exportValue: "",
44+
customContentExportType: "string",
45+
exportFormat: "",
4346
exportDateFormat: "",
4447
exportNumberFormat: "",
4548
exportType: "default"

packages/pluggableWidgets/datagrid-web/src/Datagrid.xml

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,36 @@
5858
<caption>Dynamic text</caption>
5959
<description />
6060
</property>
61+
<property key="attributeExportType" type="enumeration" required="false">
62+
<caption>Export type</caption>
63+
<description>For attribute columns, choose whether the export uses the attribute formatter or a custom Excel format.</description>
64+
<enumerationValues>
65+
<enumerationValue key="default">Default</enumerationValue>
66+
<enumerationValue key="custom">Custom</enumerationValue>
67+
</enumerationValues>
68+
</property>
6169
<property key="exportValue" type="textTemplate" dataSource="../datasource" required="false">
6270
<caption>Export value</caption>
6371
<description />
6472
</property>
65-
<property key="exportType" type="enumeration" defaultValue="default">
73+
<property key="customContentExportType" type="enumeration" required="false">
6674
<caption>Export type</caption>
67-
<description />
75+
<description>For custom content columns, choose the Excel cell type.</description>
76+
<enumerationValues>
77+
<enumerationValue key="string">String</enumerationValue>
78+
<enumerationValue key="number">Number</enumerationValue>
79+
<enumerationValue key="date">Date</enumerationValue>
80+
<enumerationValue key="boolean">Boolean</enumerationValue>
81+
</enumerationValues>
82+
</property>
83+
<property key="exportFormat" type="expression" required="false">
84+
<caption>Export format</caption>
85+
<description>Optional Excel format for exported number or date values (e.g. "#,##0.00", "yyyy-mm-dd"). See all formats https://docs.sheetjs.com/docs/csf/features/nf/</description>
86+
<returnType type="String" />
87+
</property>
88+
<property key="exportType" type="enumeration" defaultValue="default">
89+
<caption>Export type (legacy)</caption>
90+
<description>Deprecated. Kept for backward compatibility with existing widget configurations.</description>
6891
<enumerationValues>
6992
<enumerationValue key="default">Default</enumerationValue>
7093
<enumerationValue key="number">Number</enumerationValue>
@@ -73,13 +96,13 @@
7396
</enumerationValues>
7497
</property>
7598
<property key="exportNumberFormat" type="expression" required="false">
76-
<caption>Export number format</caption>
77-
<description>Optional Excel number format for exported numeric values (e.g. "#,##0.00", "$0.00", "0.00%"). See all formats https://docs.sheetjs.com/docs/csf/features/nf/</description>
99+
<caption>Export number format (legacy)</caption>
100+
<description>Deprecated. Kept for backward compatibility with existing widget configurations.</description>
78101
<returnType type="String" />
79102
</property>
80103
<property key="exportDateFormat" type="expression" required="false">
81-
<caption>Export date format</caption>
82-
<description>Excel date format for exported Date/DateTime values (e.g. "yyyy-mm-dd", "dd/mm/yyyy hh mm").</description>
104+
<caption>Export date format (legacy)</caption>
105+
<description>Deprecated. Kept for backward compatibility with existing widget configurations.</description>
83106
<returnType type="String" />
84107
</property>
85108
<property key="header" type="textTemplate" required="false">

0 commit comments

Comments
 (0)