Column sets

GridControl

Swap 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).

Example
Razor
C#
Item Code Description Category Qty Price Total
01-100Grading & CompactionSitework14250.004250.00
02-210Post-Tension Foundation CablesConcrete24115.002760.00
03-3102x6 Exterior Wall StudsFraming4508.753937.50
04-120Architectural Shingles 30yrRoofing6534.502242.50
05-410PEX Water Supply PipingPlumbing12145.001740.00
06-110200A Main Distribution PanelElectrical2680.001360.00
6 rows

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.

An unhandled error has occurred. Reload 🗙

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.