AutoCompleteBoxBaseSettings.CustomFiltering Property
Enables you to specify filtering rules before the server-side filtering.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v24.2.dll
NuGet Package: DevExpress.Web.Mvc5
#Declaration
public ListEditCustomFilteringEventHandler CustomFiltering { get; set; }
#Property Value
Type | Description |
---|---|
List |
A delegate method that allows you to implement custom filtering. |
#Remarks
Use the delegate specified by the CustomFiltering property 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 a delegate specified by the CustomFiltering property if items are loaded on a callback when scrolling. In this case, the ListEditCustomFilteringEventArgs.CustomHighlighting property is not in effect.
Note
The Custom
- The Combo
Box property is set to None.Settings. Properties. Incremental Filtering Mode - The Combo
Box property is set to false.Settings. Properties. Enable Callback Mode
The following example illustrates how to use the CustomFiltering property to filter the combo box items by several words through multiple columns.
@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: