Skip to main content
Tab

ASPxAutoCompleteBoxBase.CustomFiltering Event

Fires before the server-side filtering is executed.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public event ListEditCustomFilteringEventHandler CustomFiltering

Event Data

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

Property Description
CustomHighlighting Specifies rules according to which the editor highlights the filtered items.
Filter Gets the filter string.
FilterExpression Specifies the filter expression.

Remarks

Use the CustomFiltering event to filter the editor items. The delegate receives an argument of the ListEditCustomFilteringEventArgs type. The argument’s properties contains data specific to this delegate.

The editor uses the “Contains/Starts with” comparison operator if the ListEditCustomFilteringEventArgs.FilterExpression property is not specified. The ListEditCustomFilteringEventArgs.FilterExpression property is not in effect if the combo box is in custom binding mode.

The editor highlights the first occurrence of the filter string. Use the ListEditCustomFilteringEventArgs.CustomHighlighting property to specify rules according to which the editor highlights the filtered items.

The editor reraises the CustomFiltering event if items are loaded on a callback when scrolling. In this case, the ListEditCustomFilteringEventArgs.CustomHighlighting property is not in effect.

Note

The CustomFiltering event is not in effect in the following cases:

Run Demo: ASPxComboBox - Custom Filtering

Example

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

<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);
}

The result:

ASPxComboBox-CustomFilteringEvent

See Also