Skip to content

Commit 6a35ea6

Browse files
committed
chore: update changelog and openspec
1 parent d3ef8c1 commit 6a35ea6

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

packages/pluggableWidgets/datagrid-web/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
### Added
1010

11-
- We added support for using the attribute's own formatting when exporting to Excel with the "Default" export type. Numbers and dates now export with their configured precision and pattern instead of raw values.
11+
- We added support for using the attribute's own formatting when exporting to Excel with the "Default" export type. Numbers now export as numeric cells that mirror the grid's decimals and thousands grouping, and dates export using their configured pattern, instead of unformatted values.
1212

1313
### Fixed
1414

packages/pluggableWidgets/datagrid-web/openspec/design.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
### Reproduction Tests
44

5-
- Attribute number with default export type uses formatter - (unit)
6-
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "number", config: { groupDigits: true, decimalPrecision: 2 } }`
5+
- Attribute number with default export type mirrors the grid - (unit)
6+
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "number", config: { groupDigits: true } }` (Mendix Decimal attributes only expose `groupDigits` at runtime, not a fixed `decimalPrecision`)
77
- **When**: Export reads the cell
8-
- **Then**: Cell is `{ t: "n", v: 1234.56, z: "#,##0.00" }`
8+
- **Then**: Cell is `{ t: "n", v: 1234.56, z: "#,##0.########" }``#` suppresses trailing zeros so Excel renders exactly what the grid shows (`1234.56` stays `1234.56`, `0.5` stays `0.5`, integers stay integers)
99

1010
- Attribute date with default export type uses custom pattern - (unit)
1111
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "datetime", config: { type: "custom", pattern: "dd/MM/yyyy" } }`
@@ -19,10 +19,15 @@
1919
- **When**: Export reads the cell
2020
- **Then**: Cell has `z: "dd-mm-yyyy"` (locale fallback, not derived from formatter)
2121

22-
- Attribute number with no decimal precision - (unit)
23-
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "number", config: { groupDigits: false, decimalPrecision: 0 } }`
22+
- Attribute number honours explicit decimalPrecision when present - (unit)
23+
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "number", config: { groupDigits: false, decimalPrecision: 0 } }` (precision explicitly provided)
2424
- **When**: Export reads the cell
25-
- **Then**: Cell has `z: "0"` (no grouping, no decimals)
25+
- **Then**: Cell has `z: "0"` (no grouping, no decimals) — an explicit `decimalPrecision` takes priority over the grid-mirroring fallback
26+
27+
- Attribute number without grouping mirrors the grid - (unit)
28+
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "number", config: { groupDigits: false } }` (no `decimalPrecision`)
29+
- **When**: Export reads the cell
30+
- **Then**: Cell has `z: "0.########"` (no grouping, up to 8 fractional digits with trailing zeros suppressed)
2631

2732
- Attribute with formatter lacking type field - (unit)
2833
- **Given**: Attribute column with `exportType = "default"`, attribute has basic formatter (no `type` property, e.g., default mock)
@@ -48,6 +53,7 @@
4853

4954
## Notes
5055

56+
- Mendix Decimal attributes do **not** expose a fixed `decimalPrecision` on the formatter config at runtime — only `groupDigits` is present (verified against the live client). The number-default format therefore mirrors the grid using `{base}.########` (8 = the Mendix DB fractional-digit maximum) with `#` suppressing trailing zeros, rather than deriving a fixed precision. The `decimalPrecision` branch is retained for the case where a future runtime does supply it.
5157
- The `M → m` conversion is needed because Mendix uses Java-style date patterns (M = month) while Excel uses `m` for month.
5258
- `getAttributeDefaultFormat` returns `undefined` for string, boolean, and enum attributes — these fall through to existing logic (displayValue for strings, native boolean cells).
5359
- The `editorConfig` change is Studio Pro-only (design time) — no runtime test needed.

packages/pluggableWidgets/datagrid-web/openspec/proposal.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
## Why
22

3-
When exporting a Data Grid 2 to Excel with `exportType = "default"` on attribute columns, the exported cells had no Excel format applied. Numbers exported as raw values without thousand separators or decimal precision, and dates used only the browser locale fallback. Users expected "default" to mean "use the attribute's own configured format" (e.g., 2 decimal places for a Decimal, `dd/MM/yyyy` for a DateTime).
3+
When exporting a Data Grid 2 to Excel with `exportType = "default"` on attribute columns, the exported cells had no Excel format applied. Numbers exported as raw values without thousand separators or decimal precision, and dates used only the browser locale fallback. Users expected "default" to mean "export the value the way the grid shows it" (matching decimals and grouping for a Decimal, `dd/MM/yyyy` for a DateTime).
44

55
Additionally, the export type and format properties were visible in Studio Pro for dynamic text columns even though the export logic ignores them — confusing for configurators.
66

77
## Root Cause
88

99
`getCellFormat()` returned `undefined` when `exportType === "default"`, meaning no Excel format code (`z` field) was written to the cell. The attribute's `formatter` property (available on `ListAttributeValue` since Mendix 10) was never consulted.
1010

11+
A first attempt derived the number format from `config.decimalPrecision`, but testing against the live client revealed that Mendix Decimal attributes do **not** expose `decimalPrecision` at runtime — the formatter config only carries `groupDigits`. This caused `decimalPrecision ?? 0` to collapse to `0` and export whole numbers (e.g. `1234.56` became `1235`). The format is therefore derived to mirror the grid instead of relying on a precision value that never arrives.
12+
1113
The `editorConfig.ts` visibility logic only conditionally hid `exportNumberFormat`/`exportDateFormat` based on the export type value, but never hid all three export properties when `showContentAs === "dynamicText"`.
1214

1315
## What Changes
1416

1517
Package: `packages/pluggableWidgets/datagrid-web`
1618

1719
- `src/features/data-export/cell-readers.ts` — New `getAttributeDefaultFormat(props)` function reads `props.attribute.formatter` and derives an Excel format string:
18-
- `formatter.type === "number"` → builds format from `groupDigits` and `decimalPrecision` (e.g., `#,##0.00`)
20+
- `formatter.type === "number"` → builds format from `groupDigits`; when `decimalPrecision` is present it is honoured, otherwise the format mirrors the grid as `{base}.########` (up to 8 fractional digits, trailing zeros suppressed by `#`), so `1234.56` exports as `1234.56` and integers stay integers
1921
- `formatter.type === "datetime"` with `config.type === "custom"` → converts Mendix pattern to Excel format (M→m replacement)
2022
- Otherwise returns `undefined` (falls through to existing locale default for dates)
2123
- Attribute reader now branches: `exportType === "default"``getAttributeDefaultFormat()`, else → existing `getCellFormat()`.

0 commit comments

Comments
 (0)