Skip to content

Commit 6c50f43

Browse files
feat(datagrid-web): add type and format properties on columns
1 parent 4d251d4 commit 6c50f43

File tree

3 files changed

+46
-1
lines changed

3 files changed

+46
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ export function getProperties(
6565
if (column.minWidth !== "manual") {
6666
hidePropertyIn(defaultProperties, values, "columns", index, "minWidthLimit");
6767
}
68+
// Hide exportNumberFormat if exportType is not 'number'
69+
if (column.exportType !== "number") {
70+
hidePropertyIn(defaultProperties, values, "columns", index, "exportNumberFormat" as any);
71+
}
72+
// Hide exportDateFormat if exportType is not 'date'
73+
if (column.exportType !== "date") {
74+
hidePropertyIn(defaultProperties, values, "columns", index, "exportDateFormat" as any);
75+
}
6876
if (!values.advanced && platform === "web") {
6977
hideNestedPropertiesIn(defaultProperties, values, "columns", index, [
7078
"columnClass",
@@ -214,7 +222,9 @@ export const getPreview = (
214222
minWidth: "auto",
215223
minWidthLimit: 100,
216224
allowEventPropagation: true,
217-
exportValue: ""
225+
exportValue: "",
226+
exportType: "text",
227+
exportFormat: ""
218228
}
219229
];
220230
const columns = rowLayout({

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,33 @@
127127
<caption>Export value</caption>
128128
<description />
129129
</property>
130+
<property key="exportType" type="enumeration" defaultValue="text">
131+
<caption>Export type</caption>
132+
<description />
133+
<enumerationValues>
134+
<enumerationValue key="text">Text</enumerationValue>
135+
<enumerationValue key="number">Number</enumerationValue>
136+
<enumerationValue key="date">Date</enumerationValue>
137+
<enumerationValue key="boolean">Boolean</enumerationValue>
138+
</enumerationValues>
139+
</property>
140+
<property key="exportNumberFormat" type="textTemplate" required="false">
141+
<caption>Export number format</caption>
142+
<description>
143+
Optional Excel number format string to apply when exporting numeric values.
144+
You can use any valid SheetJS number format, including currency, percentage, or custom patterns
145+
(e.g. "#,##0.00", "$0.00", "0.00%").
146+
See full syntax reference here: https://docs.sheetjs.com/docs/csf/features/nf/
147+
</description>
148+
</property>
149+
<property key="exportDateFormat" type="textTemplate" required="false">
150+
<caption>Export date format</caption>
151+
<description>
152+
Optional Excel date format string to apply when exporting Date or DateTime values.
153+
Follows JavaScript date format conventions supported by SheetJS
154+
(e.g. "yyyy-mm-dd", "dd/mm/yyyy hh:mm", "mmm d, yyyy").
155+
</description>
156+
</property>
130157
<property key="header" type="textTemplate" required="false">
131158
<caption>Caption</caption>
132159
<description />

packages/pluggableWidgets/datagrid-web/typings/DatagridProps.d.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export type LoadingTypeEnum = "spinner" | "skeleton";
1717

1818
export type ShowContentAsEnum = "attribute" | "dynamicText" | "customContent";
1919

20+
export type ExportTypeEnum = "text" | "number" | "date" | "boolean";
21+
2022
export type HidableEnum = "yes" | "hidden" | "no";
2123

2224
export type WidthEnum = "autoFill" | "autoFit" | "manual";
@@ -31,6 +33,9 @@ export interface ColumnsType {
3133
content?: ListWidgetValue;
3234
dynamicText?: ListExpressionValue<string>;
3335
exportValue?: ListExpressionValue<string>;
36+
exportType: ExportTypeEnum;
37+
exportNumberFormat?: DynamicValue<string>;
38+
exportDateFormat?: DynamicValue<string>;
3439
header?: DynamicValue<string>;
3540
tooltip?: ListExpressionValue<string>;
3641
filter?: ReactNode;
@@ -67,6 +72,9 @@ export interface ColumnsPreviewType {
6772
content: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
6873
dynamicText: string;
6974
exportValue: string;
75+
exportType: ExportTypeEnum;
76+
exportNumberFormat: string;
77+
exportDateFormat: string;
7078
header: string;
7179
tooltip: string;
7280
filter: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };

0 commit comments

Comments
 (0)