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.Columns
collection. - Automatically—By setting
RadDataGrid.AutoGenerateColumns="True"
. - Mixed—By adding columns to the
RadDataGrid.Columns
collection 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
DataTemplate
to describe the content of each associated grid cell. -
Boolean column—A special
DataGridTypedColumn
implementation that presents Boolean data. -
Date column—An extended
DataGridTextColumn
that presents data of typeDateTime
. The column will create aDataGridDateFilterControl
upon triggering the filtering UI through user input. -
Image column—Represents a specific
DataGridTypedColumn
that may show the associated data through Image controls. -
Numerical column—Represents an extended
DataGridTextColumn
that shows numerical data. The column will create aDataGridNumericalFilterControl
upon triggering the filtering UI through user input. -
Text column—Represents a column that converts the content of each associated cell to a
System.String
object. -
Time column—Represents an extended
DataGridTextColumn
that presents data of typeDateTime
. The column will create aDataGridTimeFilterControl
upon triggering the filtering UI through user input. -
ComboBox column—An extended
DataGridTextColumn
that uses a ComboBox component to select a value when the cell is in edit mode.
Key Properties
-
CellDecorationStyle
—Gets or sets theStyle
object that defines the background of each cell associated with this column. TheTargetType
property of theStyle
object isRectangle
. -
CellDecorationStyleSelector
—Gets or sets theStyleSelector
instance 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 theStyle
instance that defines the appearance of theDataGridColumnHeader
component. -
SizeMode
—Gets or sets theDataGridColumnSizeMode
value that controls the way the column and its associated cells are sized horizontally.-
Fixed
—The column has a fixed width as defined by itsWidth
property. -
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 theSizeMode
property 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.