Assign Editors to Cells
- 3 minutes to read
The GridControl assigns editors to column cells based on the column’s data type. Refer to the Smart Columns Generation topic for a complete list of supported data types and corresponding data editors.
You can also use the following techniques to assign editors to column cells:
Use a DevExpress Editor
The EditSettings property allows you to choose a DevExpress Data Editor for a column.
Implement a Custom Control
Use the CellTemplate property to implement a custom cell editor for a column. You can specify any DevExpress WPF Control or Standard WPF Control.
The CellTemplate is intended for complex customization that you cannot achieve with EditSettings alone. If your want to specify and configure a DXEditor, we recommend that you use EditSettings instead. Refer to the Address Possible Issues if You Use Cell Templates section for more information.
Assign Editors Separately for Display and Edit Modes
You can use templates to define custom cell editors separately for display and edit modes.
The ColumnBase.CellEditTemplate is only used when a cell is in edit mode. Therefore, it has less impact on performance compared to CellTemplate that is used in both edit and display modes and applies to all column’s cells.
Use the ColumnBase.CellDisplayTemplate to use a different (or differently configured) editor for cells in display mode.
Template | Description |
---|---|
ColumnBase.CellDisplayTemplate / DataViewBase.CellDisplayTemplate | Defines a template that displays column values. |
ColumnBase.CellEditTemplate / DataViewBase.CellEditTemplate | Defines a template that is used to edit cell values. |
Use a Separate Editor for Automatic Filter Row
The EditSettings property affects the Automatic Filter Row. Specify the CellTemplate to assign a different editor for data cells:
<dxg:GridColumn FieldName="Date">
<!-- Automatic Filter Row uses TextEdit -->
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings/>
</dxg:GridColumn.EditSettings>
<!-- Data cells use DateEdit -->
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxe:DateEdit x:Name="PART_Editor"/>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
Address Possible Issues if You Use Cell Templates
The CellDisplayTemplate and CellEditTemplate override the CellTemplate for the same column.
The CellTemplate does not affect data processing (sorting, grouping, filtering, summary calculation) and export.
When you use the CellTemplate, specify the EditSettings value to configure the formatting settings, data processing (sorting, grouping, filtering, summary calculation), and export. The editor itself specified in the EditSettings property is ignored.
Performance depends on the current cell editor. The difference is not noticeable when you use lightweight controls (for example, TextBlock). When you use heavier controls, the EditSettings property allows you to gain maximum performance.
Process User Actions
The GridControl has the following events to process user actions:
Event | Description |
---|---|
DataViewBase.GetIsEditorActivationAction | Allows you to specify whether an action (key press, text input, or left mouse button click) activates the focused editor. |
DataViewBase.ProcessEditorActivationAction | Allows you to make the focused editor process an activation action. |
DataViewBase.GetActiveEditorNeedsKey | Allows you to specify whether an active editor responds to keys a user presses. |
Change How Data Cells Look in Printed and Exported Documents
The EditSettings property affects the cell appearance when you print the GridControl‘s data or export it in WYSIWYG mode.
Use the PrintCellStyle property to customize cell appearance when you print or export the grid.
Comparative Table
Approach | Supports Printing / Exporting | Supports Standard WPF Controls | Supports Template Selector | Works in Edit Mode | |
---|---|---|---|---|---|