Skip to main content
All docs
V25.1

ComboBox - Data Shaping

  • 6 minutes to read

Group Data

The Blazor ComboBox allows you to organize list items into groups. This enhance user experience by allowing users to locate required values faster. To group data, specify the GroupFieldName property. Values from the specified field appear within group headers.

Note the following specifics:

  • The ComboBox supports only one group level.
  • Users cannot collapse groups.
  • Group headers do not take part in search operations.
  • Multi-column ComboBox controls also support groups.
  • You can use the GroupHeaderDisplayTemplate property to customize group headers.

The following code organizes data items into groups based on the Country data source field:

@inject NwindDataService NwindDataService

<DxComboBox Data="@Data"
            @bind-Value="Value"
            TextFieldName="@nameof(Customer.ContactName)"
            GroupFieldName="@nameof(Customer.Country)"
            SearchMode="@ListSearchMode.AutoSearch"
            SearchFilterCondition="@ListSearchFilterCondition.Contains"
            InputId="cbGrouping"/>

@code {
    IEnumerable<Customer> Data { get; set; }
    Customer Value { get; set; }
    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetCustomersAsync();
        Value = Data.FirstOrDefault(x => x.Country == "Argentina");
    }
}

ComboBox - Group Data

Run Demo: ComboBox – Group Data

Search and Filter Data

The DevExpress Blazor ComboBox can search for text, and filter and highlight search results. Use the following API members to enable search and filter capabilities:

  • SearchMode — Specifies whether the component can search for text users type in the edit box. When the AutoSearch mode is active, the ComboBox filters items based on the search string and highlights matches. All visible columns are searched.

    Users can use special characters to create composite criteria. Refer to the following section for additional information: Search Syntax.

  • SearchFilterCondition — Specifies the search and filter condition (Contains, Equals, or StartsWith).

  • SearchTextParseMode — Specifies how the component combines words into the search query. If search text contains multiple words separated by spaces, words can be treated as single or individual conditions. The GroupWordsByAnd, GroupWordsByOr, and ExactMatch modes are available.
  • SearchEnabled - Specifies whether the component can search text in cells of the current column.
<DxComboBox Data="Staff.DataSource" 
            @bind-Value="@Value" 
            SearchMode="ListSearchMode.AutoSearch"
            SearchFilterCondition="ListSearchFilterCondition.Contains">
    <Columns>
        <DxListEditorColumn FieldName="FirstName"></DxListEditorColumn>
        <DxListEditorColumn FieldName="LastName"></DxListEditorColumn>
        <DxListEditorColumn FieldName="Department" SearchEnabled="false"></DxListEditorColumn>
    </Columns>
</DxComboBox>

@code {
    string Value { get; set; }
}

When a user types text into the edit box, the ComboBox filters and highlights search results.

ComboBox - Filter Data

Run Demo: ComboBox - Search and Filter Data

Note

If you use the EditBoxDisplayTemplate property and need to enable filter mode, you should add a DxInputBox object to the template markup.

Disabled Items

You can disable individual items in the ComboBox’s drop-down list. To do this, use the DisabledFieldName property. The property specifies a Boolean field that stores each item’s enabled or disabled state. Disabled items are grayed out and cannot be selected.

Note

Disabled items can improve component usability, but cannot replace adequate security measures. Users may still be able to select disabled items on the client side, so you should implement appropriate security checks in your code.

@inject NwindDataService NwindDataService

<DxComboBox Data="@Products"
            @bind-Value="@SelectedProduct"
            NullText="Select a product without discount..."
            TextFieldName="@(nameof(Product.ProductName))"
            DisabledFieldName="@(nameof(Product.Discontinued))">
</DxComboBox>

@code {
    IEnumerable<Product> Products { get; set; }
    Product SelectedProduct { get; set; }
    protected override async Task OnInitializedAsync() {
        Products = await NwindDataService.GetProductsAsync();
        SelectedProduct = Products.FirstOrDefault();
    }
}

ComboBox - Disabled Items

Run Demo: ComboBox – Disabled Items