Skip to content

Commit bcdfc0f

Browse files
docs(comboBox): filter operator
1 parent 2a57705 commit bcdfc0f

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

components/autocomplete/filter.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ To control when the filter list appears, set the `MinLength` parameter. This can
5858
>caption Choose FilterOperator
5959
6060
````CSHTML
61+
@* Type something in the input to see items filtered. Choose a new filter operator and repeat *@
62+
6163
<label>
6264
Choose filter operator:
6365
<select @bind="filterOperator">

components/combobox/filter.md

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The ComboBox component allows the user to filter the available items by their te
1414

1515
To enable filtering, set the `Filterable` parameter to `true`.
1616

17-
The filter operator is `contains`, it looks in the `TextField`, and filtering is reset when the dropdown closes.
17+
Filtering ignores casing and the default filter operator is `contains`. Filtering looks in the `TextField`, and the filter is reset when the dropdown closes. You can choose a different operator through the `FilterOperator` parameter that takes a member of the `Telerik.Blazor.StringFilterOperator` enum.
1818

1919
>caption Filtering in the ComboBox
2020
@@ -58,6 +58,63 @@ The filter operator is `contains`, it looks in the `TextField`, and filtering is
5858
}
5959
````
6060

61+
>caption Choose Filter Operator
62+
63+
````CSHTML
64+
@* Type something in the input to see items filtered. Choose a new filter operator and repeat *@
65+
66+
<label for="filterOperatorChoice">
67+
Choose filter operator:
68+
<select @bind="@filterOperator" class="form-control" style="width: 130px;margin-bottom:1rem;"
69+
id="filterOperatorChoice">
70+
@foreach (var possibleFilter in Enum.GetValues(typeof(StringFilterOperator)))
71+
{
72+
<option value="@possibleFilter">@possibleFilter</option>
73+
}
74+
</select>
75+
</label>
76+
77+
@SelectedValue
78+
<br />
79+
80+
<TelerikComboBox Data="@Data"
81+
Filterable="true" FilterOperator="@filterOperator"
82+
Placeholder="Find a car by typing part of its make"
83+
@bind-Value="@SelectedValue" TextField="Make" ValueField="Id">
84+
</TelerikComboBox>
85+
86+
@code {
87+
StringFilterOperator filterOperator { get; set; } = StringFilterOperator.Contains;
88+
List<Car> Data { get; set; } = new List<Car>
89+
{
90+
new Car { Id = 1, Make = "Honda" },
91+
new Car { Id = 1, Make = "Opel" },
92+
new Car { Id = 1, Make = "Audi" },
93+
new Car { Id = 1, Make = "Lancia" },
94+
new Car { Id = 1, Make = "BMW" },
95+
new Car { Id = 1, Make = "Mercedes" },
96+
new Car { Id = 1, Make = "Tesla" },
97+
new Car { Id = 1, Make = "Vw" },
98+
new Car { Id = 1, Make = "Alpha Romeo" },
99+
new Car { Id = 1, Make = "Chevrolet" },
100+
new Car { Id = 1, Make = "Ford" },
101+
new Car { Id = 1, Make = "Cadillac" },
102+
new Car { Id = 1, Make = "Dodge" },
103+
new Car { Id = 1, Make = "Jeep" },
104+
new Car { Id = 1, Make = "Chrysler" },
105+
new Car { Id = 1, Make = "Lincoln" }
106+
};
107+
108+
int? SelectedValue { get; set; }
109+
110+
public class Car
111+
{
112+
public int Id { get; set; }
113+
public string Make { get; set; }
114+
}
115+
}
116+
````
117+
61118

62119
## See Also
63120

components/combobox/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ The ComboBox is a generic component and its type is determined by the type of th
6161
* `Data` - allows you to provide the data source. Required.
6262
* `Enabled` - whether the component is enabled.
6363
* `Filterable` - whether [filtering]({%slug components/combobox/filter%}) is enabled for the end user.
64+
* `FilterOperator` - the method of [filtering]({%slug components/combobox/filter%}) the items. Defaults to `StartsWith`.
6465
* `Placeholder` - the text the user sees as a hint when no item is selected (the `Value` is `null` or an empty string).
6566
* `PopupHeight` - the height of the expanded dropdown list element.
6667
* `TItem` - the type of the model to which the component is bound. Required if you can't provide `Data` or `Value`. Determines the type of the reference object.

0 commit comments

Comments
 (0)