Back to Devexpress

ASPxGridBase.FilterControlCriteriaValueEditorCreate Event

aspnet-devexpress-dot-web-dot-aspxgridbase-d5f096dc.md

latest4.4 KB
Original Source

ASPxGridBase.FilterControlCriteriaValueEditorCreate Event

Allows you to replace the default criteria value editor with a custom editor.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
public event FilterControlCriteriaValueEditorCreateEventHandler FilterControlCriteriaValueEditorCreate
vb
Public Event FilterControlCriteriaValueEditorCreate As FilterControlCriteriaValueEditorCreateEventHandler

Event Data

The FilterControlCriteriaValueEditorCreate event's data class is FilterControlCriteriaValueEditorCreateEventArgs. The following properties provide information specific to this event:

PropertyDescription
ColumnGets the column whose editor is being created.
EditorPropertiesGets or sets the processed editor properties.
ValueGets or sets the processed editor value.

Remarks

The FilterControlCriteriaValueEditorCreate event fires for an editor in the criteria value, and enables you to replace the default editor with a custom editor.

To change the editor, use the event parameter’s EditorProperties property. The editor’s value is specified by the Value property.

csharp
protected void grid_FilterControlCriteriaValueEditorCreate(object sender, FilterControlCriteriaValueEditorCreateEventArgs e) {
    if(e.Column.PropertyName == "NeedAlert") {
        e.EditorProperties = CreateComboBoxProperties(e.Value);
    }
}
EditPropertiesBase CreateComboBoxProperties(object value) {
    bool v = value != null && (bool)value;
    var props = new ComboBoxProperties();
    props.ValueType = typeof(bool);
    props.Items.Add(new ListEditItem("Need alert", true) { Selected = v });
    props.Items.Add(new ListEditItem("Is's ok", false) { Selected = !v });
    return props;
}
vb
Protected Sub grid_FilterControlCriteriaValueEditorCreate(ByVal sender As Object, ByVal e As FilterControlCriteriaValueEditorCreateEventArgs)
    If e.Column.PropertyName = "NeedAlert" Then
        e.EditorProperties = CreateComboBoxProperties(e.Value)
    End If
End Sub

Private Function CreateComboBoxProperties(ByVal value As Object) As EditPropertiesBase
    Dim v As Boolean = value IsNot Nothing AndAlso DirectCast(value, Boolean)
    Dim props = New ComboBoxProperties()
    props.ValueType = GetType(Boolean)
    props.Items.Add(New ListEditItem("Need alert", True) With {.Selected = v})
    props.Items.Add(New ListEditItem("Is's ok", False) With {.Selected = Not v})
    Return props
End Function

Run Demo: Grid - Filter ControlRun Demo: Card View - Filter ControlRun Demo: Vertical Grid - Filter Control

See Also

Grid - Filter Control

Card View - Filter Control

Vertical Grid - Filter Control

ASPxGridBase Class

ASPxGridBase Members

DevExpress.Web Namespace