Skip to content

Commit 0945978

Browse files
feat(datagrid-web): add type and format properties on columns
1 parent 9183309 commit 0945978

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",
@@ -209,7 +217,9 @@ export const getPreview = (
209217
minWidth: "auto",
210218
minWidthLimit: 100,
211219
allowEventPropagation: true,
212-
exportValue: ""
220+
exportValue: "",
221+
exportType: "text",
222+
exportFormat: ""
213223
}
214224
];
215225
const columns = rowLayout({

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,33 @@
111111
<caption>Export value</caption>
112112
<description />
113113
</property>
114+
<property key="exportType" type="enumeration" defaultValue="text">
115+
<caption>Export type</caption>
116+
<description />
117+
<enumerationValues>
118+
<enumerationValue key="text">Text</enumerationValue>
119+
<enumerationValue key="number">Number</enumerationValue>
120+
<enumerationValue key="date">Date</enumerationValue>
121+
<enumerationValue key="boolean">Boolean</enumerationValue>
122+
</enumerationValues>
123+
</property>
124+
<property key="exportNumberFormat" type="textTemplate" required="false">
125+
<caption>Export number format</caption>
126+
<description>
127+
Optional Excel number format string to apply when exporting numeric values.
128+
You can use any valid SheetJS number format, including currency, percentage, or custom patterns
129+
(e.g. "#,##0.00", "$0.00", "0.00%").
130+
See full syntax reference here: https://docs.sheetjs.com/docs/csf/features/nf/
131+
</description>
132+
</property>
133+
<property key="exportDateFormat" type="textTemplate" required="false">
134+
<caption>Export date format</caption>
135+
<description>
136+
Optional Excel date format string to apply when exporting Date or DateTime values.
137+
Follows JavaScript date format conventions supported by SheetJS
138+
(e.g. "yyyy-mm-dd", "dd/mm/yyyy hh:mm", "mmm d, yyyy").
139+
</description>
140+
</property>
114141
<property key="header" type="textTemplate" required="false">
115142
<caption>Caption</caption>
116143
<description />

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

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

1616
export type ShowContentAsEnum = "attribute" | "dynamicText" | "customContent";
1717

18+
export type ExportTypeEnum = "text" | "number" | "date" | "boolean";
19+
1820
export type HidableEnum = "yes" | "hidden" | "no";
1921

2022
export type WidthEnum = "autoFill" | "autoFit" | "manual";
@@ -29,6 +31,9 @@ export interface ColumnsType {
2931
content?: ListWidgetValue;
3032
dynamicText?: ListExpressionValue<string>;
3133
exportValue?: ListExpressionValue<string>;
34+
exportType: ExportTypeEnum;
35+
exportNumberFormat?: DynamicValue<string>;
36+
exportDateFormat?: DynamicValue<string>;
3237
header?: DynamicValue<string>;
3338
tooltip?: ListExpressionValue<string>;
3439
filter?: ReactNode;
@@ -65,6 +70,9 @@ export interface ColumnsPreviewType {
6570
content: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };
6671
dynamicText: string;
6772
exportValue: string;
73+
exportType: ExportTypeEnum;
74+
exportNumberFormat: string;
75+
exportDateFormat: string;
6876
header: string;
6977
tooltip: string;
7078
filter: { widgetCount: number; renderer: ComponentType<{ children: ReactNode; caption?: string }> };

0 commit comments

Comments
 (0)