Infragistics
Close
Angular React Web Components Blazor Blazor
Open Source

Combo Component Features

The Blazor Combo binds to local data, filters its options as the user types, groups them by a data field, and can be disabled.

Live Demo

Features

Data Binding

The following snippets bind the Blazor Combo to a local list of US states through its data property, storing the code of each state and showing its name. The keys that the Combo reads from each item are described in Data Binding in the Combo Overview topic.

<IgbCombo @bind-Value="selectedStates" Data="usStates" ValueKey="Id" DisplayKey="Name" />

@code {
    // Items such as new UsState { Id = "CT", Name = "Connecticut", Region = "New England" }
    private List<UsState> usStates = UsStatesData.States;
    private string[] selectedStates = [];
}

IgbCombo infers its value type from Data and @bind-Value. The Blazor snippets in the rest of this topic leave them out, so add them back when you copy a snippet.

Filtering

The Blazor Combo filters its list of options as the user types in the search input of the dropdown. Filtering is on by default. Set disableFiltering to turn it off, which also hides the search input.

To let users switch the search between case-sensitive and case-insensitive, set caseSensitiveIcon. The Combo then shows a case-sensitive icon in its search input. The icon has no effect while filtering is disabled, because the search input is hidden.

@* Shows the case-sensitive icon in the search input *@
<IgbCombo CaseSensitiveIcon="true" />

@* Turns filtering off, which also hides the search input *@
<IgbCombo DisableFiltering="true" />

Filtering Options

The filteringOptions property configures how the Blazor Combo matches the search text:

  • filterKey - the data field to search in. Defaults to the field set by displayKey.
  • caseSensitive - whether the search is case-sensitive. Defaults to false. The case-sensitive icon toggles this value.
  • matchDiacritics - whether accented letters match only themselves, so that é doesn’t match e. Defaults to false.

In Blazor, set these options through an IgbFilteringOptions object, as FilterKey, CaseSensitive and MatchDiacritics.

The following snippet searches the region of each state instead of its name, and makes the search case-sensitive:

<IgbCombo FilteringOptions="@filteringOptions" />

@code {
    private IgbFilteringOptions filteringOptions = new IgbFilteringOptions
    {
        FilterKey = "Region",
        CaseSensitive = true
    };
}

Search Input Focus

When the dropdown of the Blazor Combo opens, its search input receives focus.

Set autofocusList to focus the list of options instead. On mobile devices, this keeps the software keyboard from opening with the dropdown.

<IgbCombo AutofocusList="true" />

Grouping

Set groupKey to a field of the data items to group the options of the Blazor Combo under a header for each value of that field:

In Blazor, the key is the name of the C# property, such as Region:

<IgbCombo GroupKey="Region" />

The groupKey property takes effect only when the data items are objects.

Sorting Direction

The groupSorting property sets the order of the groups in the Blazor Combo: asc (the default) sorts them in ascending order, desc in descending order, and none keeps them in the order their first items appear in the data. The items inside each group keep their order in the data.

In Blazor, set it to a GroupingDirection value: Asc, Desc or None.

<IgbCombo GroupSorting="GroupingDirection.Desc" />

Clear Button

The Blazor Combo shows a clear button in its input while at least one option is selected, and clicking the button clears the selection. Set disableClear to hide the button:

<IgbCombo DisableClear="true" />

Autofocus

Set autofocus to focus the Blazor Combo when the page loads:

<IgbCombo Autofocus="true" />

API References

Additional Resources

Use the following Blazor resources to learn more about the Combo: