Expression Editor Customization
You can customize the Expression Editor. For example, the image below shows the expression editor with the following changes:
- The Columns category is renamed to Fields.
- The Now function is removed from the date-time functions list.
Perform the following steps to customize the expression editor:
- Handle the DataViewBase.UnboundExpressionEditorCreated (or PivotGridControl.UnboundExpressionEditorCreated) event.
Use one of the following properties to obtain the expression editor:
- ExpressionEditorCreatedEventArgsBase.AutoCompleteExpressionEditorControl – the expression editor in AutoComplete mode, or
- ExpressionEditorCreatedEventArgsBase.ExpressionEditorControl – the expression editor in Standard mode.
- Specify the required expression editor’s properties.
The following code sample demonstrates how to customize the AutoComplete expression editor as shown in the image above:
<dxg:GridControl>
<!---->
<dxg:GridControl.View>
<dxg:TableView UnboundExpressionEditorCreated="OnUnboundExpressionEditorCreated" />
</dxg:GridControl.View>
</dxg:GridControl>
void OnUnboundExpressionEditorCreated(object sender, UnboundExpressionEditorEventArgs e) {
var expressionEditorContext = e.AutoCompleteExpressionEditorControl.Context;
var nowFunction = expressionEditorContext.Functions.FirstOrDefault(f => string.Equals(f.Name, "now", StringComparison.OrdinalIgnoreCase));
if (nowFunction != null) {
expressionEditorContext.Functions.Remove(nowFunction);
}
foreach (var columnInfo in expressionEditorContext.Columns) {
columnInfo.Category = "Fields";
}
}
See Also