Columns Overview
The DataGrid provides a set of approaches for defining its columns.
The following strategies are available:
- Manually—By adding columns to the
RadDataGrid.Columnscollection. - Automatically—By setting
RadDataGrid.AutoGenerateColumns="True". - Mixed—By adding columns to the
RadDataGrid.Columnscollection and also settingRadDataGrid.AutoGenerateColumns="True".
When RadDataGrid.AutoGenerateColumns="True", the DataGrid generates column types depending on the incoming data.
The DataGrid also supports column reordering by default. To enable or disable column reordering, use the RadDataGrid.UserColumnReorderMode property.
Column Types
The DataGrid provides the following type of columns:
-
Template column—Represents a column that uses a
DataTemplateto describe the content of each associated grid cell. -
Boolean column—A special
DataGridTypedColumnimplementation that presents Boolean data. -
Date column—An extended
DataGridTextColumnthat presents data of typeDateTime. The column will create aDataGridDateFilterControlupon triggering the filtering UI through user input. -
Image column—Represents a specific
DataGridTypedColumnthat may show the associated data through Image controls. -
Numerical column—Represents an extended
DataGridTextColumnthat shows numerical data. The column will create aDataGridNumericalFilterControlupon triggering the filtering UI through user input. -
Text column—Represents a column that converts the content of each associated cell to a
System.Stringobject. -
Time column—Represents an extended
DataGridTextColumnthat presents data of typeDateTime. The column will create aDataGridTimeFilterControlupon triggering the filtering UI through user input. -
ComboBox column—An extended
DataGridTextColumnthat uses a ComboBox component to select a value when the cell is in edit mode.
Key Properties
-
CellDecorationStyle—Gets or sets theStyleobject that defines the background of each cell associated with this column. TheTargetTypeproperty of theStyleobject isRectangle. -
CellDecorationStyleSelector—Gets or sets theStyleSelectorinstance that allows for a dynamic decoration on a per-cell basis. -
Header—Gets or sets the content that will be displayed in the header UI, which represents the column. -
HeaderStyle—Gets or sets theStyleinstance that defines the appearance of theDataGridColumnHeadercomponent. -
SizeMode—Gets or sets theDataGridColumnSizeModevalue that controls the way the column and its associated cells are sized horizontally.-
Fixed—The column has a fixed width as defined by itsWidthproperty. -
Stretch—The column is stretched to the available width proportionally to its desired width. -
Auto—The columns is sized to its desired width. That is the maximum desired width of all associated cells.
-
-
Width—Gets or sets the fixed width for the column. Applicable when theSizeModeproperty is set toDataGridColumnSizeMode.Fixed. -
ActualWidth—Gets the actual width of the column. -
IsAutoGenerated—Gets a value indication whether the column is auto-generated internally. -
SortDirection—Gets or sets a value that defines the visual state of theSortingDirectionGlyph. This property is used for visualization purposes only and does not affect the actual sort state of the column. To add sorting to the column, you have to use a Sort Descriptor. -
CanUserEdit(bool)—Gets or sets a value indicating whether the user can edit the values in this column. -
CanUserFilter(bool)—Gets or sets a value indicating whether the user can filter the data by the values in the column using the built-in filtering UI. -
CanUserGroup(bool)—Gets or sets a value indicating whether the user can group the data by the values in the column using the built-in grouping UI. -
CanUserSort(bool)—Gets or sets a value indicating whether the user can sort the data by the values in the column using the built-in sorting UI. -
CanUserReorder(bool)—Gets or sets a value indicating whether the user can reorder the column. -
IsVisible(bool)—Gets a value indicating if a specific column will be visualized.