Skip to content

Commit 1e6e1fd

Browse files
committed
docs(datagrid-web): add openspec for WC-3441 export column enhancements
1 parent aa923ad commit 1e6e1fd

4 files changed

Lines changed: 114 additions & 0 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: tdd-refactor
2+
created: 2026-06-24
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
## Test Cases
2+
3+
### Reproduction Tests
4+
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 } }`
7+
- **When**: Export reads the cell
8+
- **Then**: Cell is `{ t: "n", v: 1234.56, z: "#,##0.00" }`
9+
10+
- Attribute date with default export type uses custom pattern - (unit)
11+
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "datetime", config: { type: "custom", pattern: "dd/MM/yyyy" } }`
12+
- **When**: Export reads the cell
13+
- **Then**: Cell is `{ t: "d", v: <stripped-date>, z: "dd/mm/yyyy" }` (M→m converted for Excel)
14+
15+
### Edge Cases
16+
17+
- Attribute date with non-custom datetime config falls back to locale default - (unit)
18+
- **Given**: Attribute column with `exportType = "default"`, attribute has `formatter = { type: "datetime", config: { type: "date" } }`
19+
- **When**: Export reads the cell
20+
- **Then**: Cell has `z: "dd-mm-yyyy"` (locale fallback, not derived from formatter)
21+
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 } }`
24+
- **When**: Export reads the cell
25+
- **Then**: Cell has `z: "0"` (no grouping, no decimals)
26+
27+
- Attribute with formatter lacking type field - (unit)
28+
- **Given**: Attribute column with `exportType = "default"`, attribute has basic formatter (no `type` property, e.g., default mock)
29+
- **When**: Export reads the cell
30+
- **Then**: Cell has `z: undefined` for numbers, locale fallback for dates (graceful degradation)
31+
32+
### Regression Tests
33+
34+
- Custom export type still uses explicit format - (unit)
35+
- **Given**: Attribute column with `exportType = "number"` and `exportNumberFormat = "#,##0.00"`
36+
- **When**: Export reads the cell
37+
- **Then**: Cell uses the explicit format, NOT the attribute formatter
38+
39+
- Dynamic text always exports as string regardless of export settings - (unit)
40+
- **Given**: Dynamic text column with any `exportType` set
41+
- **When**: Export reads the cell
42+
- **Then**: Cell is always `{ t: "s" }`, export type ignored
43+
44+
- Custom content export unchanged - (unit)
45+
- **Given**: Custom content column with `exportType = "number"` and `exportValue = "1234.56"`
46+
- **When**: Export reads the cell
47+
- **Then**: Cell is `{ t: "n", v: 1234.56, z: <format> }` (same as before)
48+
49+
## Notes
50+
51+
- The `M → m` conversion is needed because Mendix uses Java-style date patterns (M = month) while Excel uses `m` for month.
52+
- `getAttributeDefaultFormat` returns `undefined` for string, boolean, and enum attributes — these fall through to existing logic (displayValue for strings, native boolean cells).
53+
- The `editorConfig` change is Studio Pro-only (design time) — no runtime test needed.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
## Why
2+
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).
4+
5+
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.
6+
7+
## Root Cause
8+
9+
`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.
10+
11+
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"`.
12+
13+
## What Changes
14+
15+
Package: `packages/pluggableWidgets/datagrid-web`
16+
17+
- `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`)
19+
- `formatter.type === "datetime"` with `config.type === "custom"` → converts Mendix pattern to Excel format (M→m replacement)
20+
- Otherwise returns `undefined` (falls through to existing locale default for dates)
21+
- Attribute reader now branches: `exportType === "default"``getAttributeDefaultFormat()`, else → existing `getCellFormat()`.
22+
23+
- `src/Datagrid.editorConfig.ts` — When `showContentAs === "dynamicText"`, hide `exportType`, `exportNumberFormat`, and `exportDateFormat` properties in Studio Pro.
24+
25+
## Impact
26+
27+
- Attribute columns with `exportType = "default"` now export with their configured format. This is an enhancement, not a breaking change — previously these cells had no format, now they have one.
28+
- No XML property changes. No migration needed.
29+
- No behavioral change for `exportType = "number"` / `"date"` / `"boolean"` (custom path unchanged).
30+
- Dynamic text columns: cosmetic-only change in Studio Pro property panel (properties hidden). Runtime behavior identical.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## 1. Test Setup
2+
3+
- [x] 1.1 Write test: attribute number with default exportType uses formatter config to derive Excel format
4+
- [x] 1.2 Write test: attribute date with default exportType and custom pattern uses converted pattern
5+
- [x] 1.3 Write test: attribute date with non-custom config falls back to locale default
6+
- [x] 1.4 Write test: attribute number with groupDigits=false and decimalPrecision=0 produces format "0"
7+
8+
## 2. Implementation
9+
10+
- [x] 2.1 Add `getAttributeDefaultFormat(props)` function in `cell-readers.ts` that reads `props.attribute.formatter` and derives Excel format string
11+
- [x] 2.2 Branch attribute reader: `exportType === "default"` calls `getAttributeDefaultFormat()`, else calls existing `getCellFormat()`
12+
- [x] 2.3 Hide `exportType`, `exportNumberFormat`, `exportDateFormat` in editorConfig when `showContentAs === "dynamicText"`
13+
14+
## 3. Refactoring
15+
16+
- [x] 3.1 No refactoring needed — implementation is minimal and isolated
17+
18+
## 4. Verification
19+
20+
- [x] 4.1 All 221 tests passing (4 new + 217 existing)
21+
- [x] 4.2 Full test suite passes (no regressions)
22+
- [x] 4.3 Build compiles without TypeScript errors
23+
- [x] 4.4 PR submitted and reviewed
24+
25+
## Notes
26+
27+
- No XML property changes were needed — existing `exportType` enum with "default" value covers the use case.
28+
- The `formatter` property is available on `ListAttributeValue` since Mendix 10 runtime.
29+
- iobuhov review feedback: use consistent assertion syntax (assert `cell.v` in all date tests). Fixed.

0 commit comments

Comments
 (0)