Skip to main content
Tab

ListEditCustomFilteringEventArgs.Filter Property

Gets the filter string.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.2.dll

NuGet Package: DevExpress.Web

#Declaration

public string Filter { get; }

#Property Value

Type Description
String

The filter string.

#Remarks

The following example illustrates how to use the CustomFiltering event to filter the combo box items by several words through multiple columns:

Web Forms:

Run Demo: ASPxComboBox - Custom Filtering

<dx:ASPxComboBox ID="ComboBox1" runat="server" EnableCallbackMode="true" IncrementalFilteringMode="Contains"
    OnCustomFiltering="ComboBox1_CustomFiltering">
    <Columns>
        <dx:ListBoxColumn FieldName="CompanyName" Width="100%" />
        <dx:ListBoxColumn FieldName="Country" Width="70px" />
    </Columns>
</dx:ASPxComboBox>
protected void ComboBox1_CustomFiltering(object sender, DevExpress.Web.ListEditCustomFilteringEventArgs e) {
    string[] words = e.Filter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
    string[] columns = new string[] { "CompanyName", "Country" };
    e.FilterExpression = GroupOperator.And(words.Select(w => 
        GroupOperator.Or(
            columns.Select(c => 
                new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty(c), w)
            )
        )
    )).ToString();
    e.CustomHighlighting = columns.ToDictionary(c => c, c => words);
}

MVC:

Run Demo: MVC ComboBox - Custom Filtering

@Html.DevExpress().ComboBox(settings => {
    settings.Name = "cmbWithServerFiltering";
    settings.Properties.Columns.Add(column => {
        column.FieldName = "CompanyName";
    });
    settings.Properties.Columns.Add(column => {
        column.FieldName = "Country";
    });
    <!-- ... -->
    settings.CustomFiltering += (s, e) => {
        string[] words = e.Filter.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        string[] columns = new string[] { "CompanyName", "Country" };
        e.FilterExpression = GroupOperator.And(words.Select(w => 
            GroupOperator.Or(
                columns.Select(c => 
                    new FunctionOperator(FunctionOperatorType.Contains, new OperandProperty(c), w)
                )
            )
        )).ToString();
        e.CustomHighlighting = columns.ToDictionary(c => c, c => words);    
    };
}).BindList(Model).GetHtml()

Result:

ASPxComboBox-CustomFilteringEvent

See Also