Skip to content

Commit 2a57705

Browse files
docs(autoComplete): filter operator
1 parent 595c28b commit 2a57705

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

components/autocomplete/filter.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ position: 3
1212

1313
The AutoComplete component can filter the available suggestions according to the current user input, so they can find the one they need faster. To see the difference in behavior, visit the [Live Demo: AutoComplete Filtering](https://demos.telerik.com/blazor-ui/autocomplete/filtering) page.
1414

15-
To enable filtering, set the `Filterable` parameter to `true`. The filter operator is `starts with`, and it ignores casing.
15+
To enable filtering, set the `Filterable` parameter to `true`.
16+
17+
Filtering ignores casing and the default filter operator is `starts with`. You can choose a different operator through the `FilterOperator` parameter that takes a member of the `Telerik.Blazor.StringFilterOperator` enum.
1618

1719
To control when the filter list appears, set the `MinLength` parameter. This can be useful if you have a very large list of data.
1820

@@ -52,6 +54,33 @@ To control when the filter list appears, set the `MinLength` parameter. This can
5254
}
5355
````
5456

57+
58+
>caption Choose FilterOperator
59+
60+
````CSHTML
61+
<label>
62+
Choose filter operator:
63+
<select @bind="filterOperator">
64+
@foreach (var possibleFilter in Enum.GetValues(typeof(StringFilterOperator)))
65+
{
66+
<option value="@possibleFilter">@possibleFilter</option>
67+
}
68+
</select>
69+
</label>
70+
<TelerikAutoComplete Data="@Suggestions" @bind-Value="@TheValue"
71+
Filterable="true" FilterOperator="@filterOperator"
72+
Placeholder="Write 's' or 'a' to see the difference" ClearButton="true" />
73+
74+
@code{
75+
string TheValue { get; set; }
76+
StringFilterOperator filterOperator { get; set; } = StringFilterOperator.StartsWith;
77+
78+
List<string> Suggestions { get; set; } = new List<string> {
79+
"Manager", "Developer", "QA", "Technical Writer", "Support Engineer", "Sales Agent", "Architect", "Designer"
80+
};
81+
}
82+
````
83+
5584
## See Also
5685

5786
* [Live Demo: AutoComplete Filtering](https://demos.telerik.com/blazor-ui/autocomplete/filtering)

components/autocomplete/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The AutoComplete is a generic component and its type is determined by the type o
5252
* `Data` - allows you to provide the data source. Required.
5353
* `Enabled` - whether the component is enabled.
5454
* `Filterable` - whether [filtering]({%slug autocomplete-filter%}) is enabled for the end user (suggestions will get narrowed down as they type).
55+
* `FilterOperator` - the string operation that will be used for [filtering]({%slug autocomplete-filter%}). Defaults to `StartsWith`.
5556
* `MinLength` - how many characters the text has to be before the suggestions list appears. Cannot be `0`. Often works together with [filtering]({%slug autocomplete-filter%}).
5657
* `Placeholder` - the text the user sees as a hint when there is no text in the input.
5758
* `PopupHeight` - the height of the expanded dropdown list element.

0 commit comments

Comments
 (0)