Skip to content

[WC-3441] DG2: export column enhancements#2287

Merged
yordan-st merged 5 commits into
mainfrom
feat/WC-3441_DG2-export-column-enhancements
Jul 14, 2026
Merged

[WC-3441] DG2: export column enhancements#2287
yordan-st merged 5 commits into
mainfrom
feat/WC-3441_DG2-export-column-enhancements

Conversation

@yordan-st

@yordan-st yordan-st commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

When export type is set to "Default" for attribute columns, the exported Excel cells now use the attribute's own formatting (number decimals/grouping, date pattern) instead of exporting raw values without formatting.

For numbers, the exported cell mirrors what the grid shows: Mendix Decimal attributes do not expose a fixed decimal precision at runtime (only whether digits are grouped), so the format uses up to 8 fractional digits with trailing zeros suppressed. This keeps 1234.56 as 1234.56, 0.5 as 0.5, and integers as integers — instead of collapsing to whole numbers.

Also hides the export type and format properties in Studio Pro for dynamic text columns, since they have no effect.

What should be covered while testing?

  1. Attribute column with exportType "Default" and a Decimal attribute → exported cell is a numeric cell that mirrors the grid (e.g. 1234.56 stays 1234.56, 0.5 stays 0.5, integers stay integers; thousands grouping applied when the attribute uses it). Excel format: #,##0.######## (grouped) or 0.######## (ungrouped).
  2. Attribute column with exportType "Default" and a DateTime attribute with custom pattern dd/MM/yyyy → exported cell should have Excel format dd/mm/yyyy
  3. Attribute column with exportType "Number" or "Date" (custom) → still uses the manually specified export format (unchanged behavior)
  4. Dynamic text column → Studio Pro should NOT show export type, export number format, or export date format properties
  5. Custom content columns → unchanged behavior, all export types still work
  6. Existing configurations with no changes → no regression, everything exports as before

@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from 6696f2e to 39c37d2 Compare June 22, 2026 16:01
@yordan-st yordan-st marked this pull request as ready for review June 22, 2026 16:11
@yordan-st yordan-st requested a review from a team as a code owner June 22, 2026 16:11
@github-actions

This comment has been minimized.

@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from 39c37d2 to 96a5c83 Compare June 23, 2026 12:10
@github-actions

This comment has been minimized.

iobuhov
iobuhov previously approved these changes Jun 23, 2026
@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from c94f30c to adc9e02 Compare June 24, 2026 12:51
@github-actions

This comment has been minimized.

@yordan-st yordan-st requested a review from iobuhov June 24, 2026 13:11
@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from adc9e02 to 1e6e1fd Compare July 1, 2026 13:43
@github-actions

This comment has been minimized.

@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from 827f4bb to d1dd27f Compare July 10, 2026 13:02
@github-actions

This comment has been minimized.

@yordan-st yordan-st closed this Jul 13, 2026
@yordan-st yordan-st reopened this Jul 13, 2026
…trailing dot

A static `{base}.########` mask emits the literal decimal point even when
all fractional `#` digits collapse, so whole numbers exported as `1983.`
and broke the export e2e test. Count the fractional digits from the value
itself instead, so integers use `0` (no dot) and decimals mirror the grid.
@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from d1dd27f to 5e0fb1f Compare July 14, 2026 08:30
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
packages/pluggableWidgets/datagrid-web/src/features/data-export/cell-readers.ts New getAttributeDefaultFormat() function; attribute reader now branches on exportType === "default" to apply the attribute's own formatter
packages/pluggableWidgets/datagrid-web/src/features/data-export/__tests__/cell-readers.spec.ts 7 new test cases covering number formatter, date formatter, edge cases (no decimalPrecision, whole numbers)
packages/pluggableWidgets/datagrid-web/src/Datagrid.editorConfig.ts Hides all three export properties when showContentAs === "dynamicText"
packages/pluggableWidgets/datagrid-web/CHANGELOG.md Added and Fixed entries under [Unreleased]
packages/pluggableWidgets/datagrid-web/openspec/*.{yaml,md} OpenSpec tracking artifacts (design, proposal, tasks)

Skipped (out of scope): dist/, pnpm-lock.yaml

CI check output was unavailable during this review (tool approval required).


Findings

⚠️ Low — window.mx locale path in getDefaultDateFormat has no test coverage

File: packages/pluggableWidgets/datagrid-web/src/features/data-export/cell-readers.ts line 74–78
Note: getDefaultDateFormat() has two branches: the locale-aware path (window.mx?.session.getConfig().locale.patterns.date with M→m conversion) and the fallback "dd-mm-yyyy". All tests that exercise this function—including the new ones—rely on the fallback because window.mx is not set up in jest.setup.ts. The M→m conversion on real locale patterns is never verified.

This is a pre-existing gap (function was not introduced in this PR), but the new "default exportType for date attribute" path makes it more load-bearing.

Fix (non-blocking): Add a test that sets window.mx to a mock with a custom date pattern:

beforeEach(() => {
    (window as any).mx = {
        session: { getConfig: () => ({ locale: { patterns: { date: "dd/MM/yyyy" } } }) }
    };
});
afterEach(() => { delete (window as any).mx; });

it("uses locale date pattern with M→m conversion when window.mx is available", () => {
    // exportType default, date attribute, no custom formatter config
    // expects cell.z === "dd/mm/yyyy"
});

⚠️ Low — Per-value format derivation can produce column-inconsistent Excel formats

File: packages/pluggableWidgets/datagrid-web/src/features/data-export/cell-readers.ts line 141–143
Note: When decimalPrecision is absent from the formatter config, the decimal count is derived from each individual cell's value via countDecimalPlaces(value). This means two cells in the same column—1234.5 and 1234.567—will receive different format codes (0.0 vs 0.000). In Excel, per-cell formats are valid and each cell renders correctly, but the visual appearance of the column may be inconsistent.

This is an intentional design decision (documented in the proposal and comments), and it's the right call given Mendix doesn't expose decimalPrecision at runtime. No code change needed—just worth a doc note in the proposal/design for future reference.


Positives

  • The countDecimalPlaces(value) fallback elegantly solves the trailing-dot regression ("1983.") that a static 0.######## mask would have caused—the explanation in both comments and the proposal is excellent.
  • countSignificantDigits > 15 → excelString guard is correctly retained for the new exportType === "default" path, preserving precision for long identifiers.
  • Test coverage for the new feature is thorough: happy path, explicit decimalPrecision, absent decimalPrecision (grouped + ungrouped), whole-number edge case, non-custom datetime config fallback—all covered independently.
  • The editorConfig.ts change is a clean structural refactor: the original flat conditionals are replaced with a clear if/else that makes the "dynamicText hides all export props" intent obvious.
  • CHANGELOG entries are user-facing and accurately describe the behavior change without leaking implementation details.

@yordan-st yordan-st merged commit a45156f into main Jul 14, 2026
13 of 15 checks passed
@yordan-st yordan-st deleted the feat/WC-3441_DG2-export-column-enhancements branch July 14, 2026 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants