Column sets
GridControlSwap the whole column set at runtime from a list of specs, without remounting the grid.
Overview
The columns inside GridColumnsBase are ordinary Razor markup, so a @foreach over a list of column
specs defines them. Replace the list and the grid re-reads its columns in place: a different set, order, width or
Visible flag, while the component instance, its data and its selection stay. Wrap the swap in
SuspendRedraw(fields): the grid holds its rendering while the list changes, converges added and removed columns in
place and applies the order you pass; without it, new fields append after the ones the grid already knows.
Visible="false" keeps a column in the set but off the screen.
Examples
#Three column sets, one grid
Select a row, then switch between the Default, Purchasing and Minimal sets: the selection stays while the columns change. Each set is a list of ColumnSpec objects; the Purchasing set also carries a hidden Category column. Qty and Price are editable in Default, Price in Purchasing (EditMode.Batch: double-click a cell).
| Item Code | Description | Category | Qty | Price | Total |
|---|---|---|---|---|---|
| 01-100 | Grading & Compaction | Sitework | 1 | 4250.00 | 4250.00 |
| 02-210 | Post-Tension Foundation Cables | Concrete | 24 | 115.00 | 2760.00 |
| 03-310 | 2x6 Exterior Wall Studs | Framing | 450 | 8.75 | 3937.50 |
| 04-120 | Architectural Shingles 30yr | Roofing | 65 | 34.50 | 2242.50 |
| 05-410 | PEX Water Supply Piping | Plumbing | 12 | 145.00 | 1740.00 |
| 06-110 | 200A Main Distribution Panel | Electrical | 2 | 680.00 | 1360.00 |
Default set: 6 of 6 columns visible
Documentation
GridColumn (Field, HeaderText, Width, Visible, AllowEditing), GridColumnsBase and the selection events on GridControlEvents are still to be written up from Grid/GridColumn.cs and Grid/GridControlEvents.cs.