ASPxListBox.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 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 Custom
- The List
Box is set toFiltering Settings. Show Search UI false
. - The ASPx
List property is set toBox. Enable Callback Mode false
.
The following example illustrates how to use the CustomFiltering event to filter the list box items by several words through multiple columns.
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: