Skip to content

Commit 405eb0a

Browse files
akoclaude
andcommitted
docs: add DataGrid column targeting docs and examples
Update ALTER PAGE documentation across all required locations: - Skill file (.claude/skills/mendix/alter-page.md) - MDL Quick Reference (docs/01-project/) - Reference page (docs-site/src/reference/page/) - Language page (docs-site/src/language/) - Examples page (docs-site/src/examples/) - Doctype test examples (mdl-examples/doctype-tests/) All show the dotted gridName.columnName syntax for SET, INSERT, DROP, and REPLACE operations on DataGrid2 columns. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e6bd656 commit 405eb0a

File tree

6 files changed

+101
-4
lines changed

6 files changed

+101
-4
lines changed

.claude/skills/mendix/alter-page.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,30 @@ REPLACE footer1 WITH {
126126

127127
Replaces the target widget with one or more new widgets. The new widgets use the same syntax as `CREATE PAGE`.
128128

129+
### DataGrid Column Operations
130+
131+
DataGrid2 columns are addressable using dotted notation: `gridName.columnName`. The column name is derived from the attribute short name or caption (same as shown by `DESCRIBE PAGE`).
132+
133+
```sql
134+
-- SET a column property
135+
SET Caption = 'Product SKU' ON dgProducts.Code
136+
137+
-- DROP a column
138+
DROP WIDGET dgProducts.OldColumn
139+
140+
-- INSERT a column after an existing one
141+
INSERT AFTER dgProducts.Price {
142+
COLUMN Margin (Attribute: Margin, Caption: 'Margin')
143+
}
144+
145+
-- REPLACE a column
146+
REPLACE dgProducts.Description WITH {
147+
COLUMN Notes (Attribute: Notes, Caption: 'Notes')
148+
}
149+
```
150+
151+
To discover column names, run `DESCRIBE PAGE Module.PageName` and look at the COLUMN names inside the DATAGRID.
152+
129153
### ADD Variables - Add a Page Variable
130154

131155
```sql

docs-site/src/examples/alter-page.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,31 @@ ALTER PAGE CRM.Customer_Edit {
8282
};
8383
```
8484

85+
## Modify DataGrid Columns
86+
87+
Target columns using dotted notation `gridName.columnName`:
88+
89+
```sql
90+
-- Add a column
91+
ALTER PAGE CRM.Customer_List {
92+
INSERT AFTER dgCustomers.Email {
93+
COLUMN Phone (Attribute: Phone, Caption: 'Phone')
94+
}
95+
};
96+
97+
-- Remove a column
98+
ALTER PAGE CRM.Customer_List {
99+
DROP WIDGET dgCustomers.OldNotes
100+
};
101+
102+
-- Rename a column header
103+
ALTER PAGE CRM.Customer_List {
104+
SET Caption = 'E-mail Address' ON dgCustomers.Email
105+
};
106+
```
107+
108+
Use `DESCRIBE PAGE CRM.Customer_List` to discover column names.
109+
85110
## Works on Snippets Too
86111

87112
```sql

docs-site/src/language/alter-page.md

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,32 @@ ALTER PAGE MyModule.Order_Edit {
213213
};
214214
```
215215

216-
### Add a DataGrid Column
216+
### DataGrid Column Operations
217217

218-
Since DataGrid columns are part of the widget tree, use INSERT to add columns:
218+
DataGrid2 columns are addressable using dotted notation: `gridName.columnName`. Use `DESCRIBE PAGE` to discover column names (derived from the attribute short name or caption).
219219

220220
```sql
221+
-- Add a column after an existing one
221222
ALTER PAGE MyModule.Customer_Overview {
222-
INSERT AFTER colEmail {
223-
COLUMN colPhone (Attribute: Phone, Caption: 'Phone')
223+
INSERT AFTER dgCustomers.Email {
224+
COLUMN Phone (Attribute: Phone, Caption: 'Phone')
225+
}
226+
};
227+
228+
-- Remove a column
229+
ALTER PAGE MyModule.Customer_Overview {
230+
DROP WIDGET dgCustomers.OldColumn
231+
};
232+
233+
-- Change a column's caption
234+
ALTER PAGE MyModule.Customer_Overview {
235+
SET Caption = 'E-mail Address' ON dgCustomers.Email
236+
};
237+
238+
-- Replace a column
239+
ALTER PAGE MyModule.Customer_Overview {
240+
REPLACE dgCustomers.Notes WITH {
241+
COLUMN Description (Attribute: Description, Caption: 'Description')
224242
}
225243
};
226244
```

docs-site/src/reference/page/alter-page.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,19 @@ Removes one or more widgets by name. The widget and all its children are removed
7676

7777
Replaces a widget (and its entire subtree) with one or more new widgets.
7878

79+
### DataGrid Column Operations
80+
81+
DataGrid2 columns are addressable using dotted notation: `gridName.columnName`. The column name matches the name shown by `DESCRIBE PAGE` (derived from the attribute short name or caption).
82+
83+
All four operations (SET, INSERT, DROP, REPLACE) support dotted column references:
84+
85+
```sql
86+
SET Caption = 'Product SKU' ON dgProducts.Code
87+
DROP WIDGET dgProducts.OldColumn
88+
INSERT AFTER dgProducts.Price { COLUMN Margin (Attribute: Margin) }
89+
REPLACE dgProducts.Description WITH { COLUMN Notes (Attribute: Notes) }
90+
```
91+
7992
### SET Layout
8093

8194
Changes the page's layout without rebuilding the widget tree. Placeholder names are auto-mapped by default. If the new layout has different placeholder names, use `MAP` to specify the mapping.

docs/01-project/MDL_QUICK_REFERENCE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,6 +621,9 @@ Modify an existing page or snippet's widget tree in-place without full `CREATE O
621621
| Drop widgets | `DROP WIDGET name1, name2` | Remove widgets by name |
622622
| Replace widget | `REPLACE widgetName WITH { widgets }` | Replace widget subtree |
623623
| Pluggable prop | `SET 'showLabel' = false ON cbStatus` | Quoted name for pluggable widgets |
624+
| Set column prop | `SET Caption = 'New' ON dgGrid.colName` | Dotted ref targets DataGrid column |
625+
| Drop column | `DROP WIDGET dgGrid.colName` | Remove a DataGrid column |
626+
| Insert column | `INSERT AFTER dgGrid.colName { COLUMN ... }` | Add column to DataGrid |
624627
| Add variable | `ADD Variables $name: Type = 'expr'` | Add a page variable |
625628
| Drop variable | `DROP Variables $name` | Remove a page variable |
626629
| Set layout | `SET Layout = Module.LayoutName` | Change page layout, auto-maps placeholders |

mdl-examples/doctype-tests/03-page-examples.mdl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,20 @@ ALTER PAGE PgTest.P033b_DataGrid_ColumnProperties {
22592259
SET Layout = Atlas_Core.Atlas_TopBar;
22602260
};
22612261

2262+
-- MARK: ALTER PAGE DataGrid Column Operations
2263+
2264+
-- =============================================================================
2265+
-- ALTER PAGE - DataGrid Column Operations (dotted widget references)
2266+
-- =============================================================================
2267+
--
2268+
-- DataGrid2 columns are addressable using gridName.columnName syntax.
2269+
-- Column names are derived from the attribute short name or caption.
2270+
2271+
-- DROP a column by dotted reference
2272+
ALTER PAGE PgTest.P033b_DataGrid_ColumnProperties {
2273+
DROP WIDGET dgProducts.Description
2274+
};
2275+
22622276
-- MARK: Conditional Visibility/Editability and Responsive Widths
22632277

22642278
-- =============================================================================

0 commit comments

Comments
 (0)