ASPxAutoCompleteBoxBase.CustomFiltering Event
Fires before the server-side filtering is executed.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.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 |
---|---|
Custom |
Specifies rules according to which the editor highlights the filtered items. |
Filter | Gets the filter string. |
Filter |
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 Custom
- The ASPx
Auto is set to None.Complete Box Base. Incremental Filtering Mode - The ASPx
Auto property is set toComplete Box Base. Enable Callback Mode false
.
#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: