aspnet-devexpress-dot-web-dot-aspxlistbox-b6dde977.md
Fires before the server-side filtering is executed.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
public event ListEditCustomFilteringEventHandler CustomFiltering
Public Event CustomFiltering As ListEditCustomFilteringEventHandler
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. |
Use the CustomFiltering event to implement custom filtering logic. The CustomFiltering event is reraised if items are loaded on a callback when scrolling.
Use the ListEditCustomFilteringEventArgs.FilterExpression property to specify the filter expression based on the Criteria Operator syntax. If the ListEditCustomFilteringEventArgs.FilterExpression property is not specified, the “Contains/Starts with” comparison operator is used by default.
If the ListEditCustomFilteringEventArgs.CustomHighlighting property is not set, the CustomFiltering event highlights the first occurrence of the search text typed in the editor’s filtering area (regardless of the ListEditCustomFilteringEventArgs.FilterExpression property). Use the ListEditCustomFilteringEventArgs.CustomHighlighting property to specify the custom highlighting logic. Refer to this property description for more information.
Note
The CustomFiltering event is not in effect in the following cases:
false.false.The following example illustrates how to use the CustomFiltering event to filter the list box items by several words through multiple columns.
<dx:ASPxListBox ID="ASPxListBox1" runat="server" Width="400" Height="200" DataSourceID="SqlDataSource1" EnableCallbackMode="true"
ValueType="System.String" OnCustomFiltering="ASPxListBox1_CustomFiltering" Theme="Office365">
<FilteringSettings ShowSearchUI="true" />
<Columns>
<dx:ListBoxColumn FieldName="CompanyName" Width="100%" />
<dx:ListBoxColumn FieldName="Country" Width="70px" />
</Columns>
</dx:ASPxListBox>
protected void ASPxListBox1_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:
See Also