Skip to content

fix: write a DataGrid 2 column's Visible expression - #1034

Merged
ako merged 1 commit into
mainfrom
claude/nice-einstein-a74lz4
Oct 8, 2026
Merged

ako merged 1 commit into
mainfrom
claude/nice-einstein-a74lz4

Conversation

@ako

@ako ako commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Problem

A DataGrid 2 column's Visible: expression was silently dropped. These spellings all passed check, and exec reported "Created page", but the column was stored with Expression true, i.e. always visible:

  • Visible: $showPrices
  • Visible: if … then … else …
  • visible: not(…)
  • Visible: [cond]

Only the old quoted spelling Visible: '<expr>' was kept. On the ALTER side:

  • alter page … set (Visible: <expression>) on grid column(…) was refused with "column property VisibleIf not found".
  • An inserted or replaced column also dropped Visible: false.

Cause

The visitor stores every expression spelling of Visible under the key VisibleIf, the key a page widget's conditional visibility reads. Only plain values stay under Visible. The column writers read only visible/Visible:

  • Widget engine (create): looks up the schema key plus types.ItemPropertyAliases, which had no VisibleIf alias.
  • ALTER set: resolveColumnPropertyKey uses the same table, so it refused the key.
  • ALTER insert/replace: buildColumnSpecFromAST passes the properties to widgetobj.BuildDataGrid2Column, which reads the exact key "Visible" and only as a string, so a bool false was dropped too.

This is the mirror image of bug-tests/widget-visible-expression.mdl, where page widgets read VisibleIf and dropped Visible.

Fix

  • Alias: types.ItemPropertyAliases gets visible ← VisibleIf. This fixes create and ALTER set. WidgetDefGeneratorVersion goes to 18, so existing projects regenerate their datagrid def.
  • Insert/replace: columnSpecProperties gives the column builder Visible as the string it reads (from VisibleIf, or a static false). It also passes DynamicCellClass through in any letter case.
  • Describe: prints the bare expression (via widgetConditionMDL, as page widgets do), and the output round-trips.
  • MDL-WIDGET43 (new error): a column's visible expression is evaluated once for the grid. Its widget schema declares no dataSource, unlike columnClass, so there is no row object. On Mendix 11.14.0, mx check reports CE0117 for every column whose Visible uses $currentObject; those columns only appeared to work because the value was dropped. check now refuses this on create, insert and set, and suggests a page variable or parameter.

Verification

  • Tests first, each seen failing with the symptom before the fix:
    • columnSpecProperties for each spelling (the quoted form and true are controls)
    • the def generator's visible alias
    • resolveColumnPropertyKey("VisibleIf")
    • MDL-WIDGET43 on create, insert and set (a textbox's $currentObject Visible is the control)
    • the describe round trip
  • End to end on copies of ako/TestApp (Mendix 11.14.0):
    • Before the fix, the page data stored true for each expression spelling.
    • After it, every spelling is stored on create, ALTER set and ALTER insert, using a page variable.
    • mx check reports 0 errors.
    • The describe output re-execs to an identical page.
    • exec refuses a $currentObject column Visible as MDL-WIDGET43.
  • make build && make test && make lint && make check-mdl and make check-findings all pass.

Also

  • A regression script, mdl-examples/bug-tests/datagrid-column-visible-expression.mdl.
  • The page.column syntax help and the quick reference, which showed the quoted spelling.
  • The 03-page-examples.mdl column example, which now uses visible: $showStockColumn.
  • A finding, a paragraph on docs-wiki/bug-patterns/silent-property-drop.md, and a CHANGELOG entry.

Not covered: Visible: Attr in (…) on a column is still ignored without a warning. That form lets the attribute decide visibility, and a column has no row to read it from.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P65SqmwwvbWdJVRwhYiMQw


Generated by Claude Code

Every expression spelling of a column's `Visible:` — `$showPrices`,
`if … then … else …`, `not(…)`, `[cond]` — passed check and exec and was
stored as `true`, so the column was always visible. The visitor lowers an
expression to the key VisibleIf and keeps only plain values under
Visible; the column writers read only visible/Visible.

- types.ItemPropertyAliases: `visible` <- `VisibleIf`, used by the widget
  engine on create and by ALTER `set (Visible: …) on grid column(…)`,
  which refused it as "column property VisibleIf not found". Widget defs
  regenerate at generator version 18.
- columnSpecProperties: ALTER insert/replace column hands the builder
  Visible (and DynamicCellClass in any case) as the string it reads; a
  `Visible: false` bool was dropped there too.
- describe prints the bare expression, which now round-trips.
- MDL-WIDGET43: a column's visibility is evaluated once for the grid, with
  no row object, so $currentObject there is CE0117 (measured on 11.14.0).
  check refuses it on create, insert and set.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P65SqmwwvbWdJVRwhYiMQw
@ako
ako force-pushed the claude/nice-einstein-a74lz4 branch from 0579587 to 687a09f Compare October 8, 2026 04:52
@ako
ako merged commit ed33019 into main Oct 8, 2026
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants