Back to Devexpress

DxTagBox<TData, TValue>.GroupHeaderDisplayTemplate Property

blazor-devexpress-dot-blazor-dot-dxtagbox-2-af9de78d.md

latest4.1 KB
Original Source

DxTagBox<TData, TValue>.GroupHeaderDisplayTemplate Property

Specifies the template used to display group headers when TagBox items are grouped.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public RenderFragment<TagBoxGroupHeaderDisplayTemplateContext> GroupHeaderDisplayTemplate { get; set; }

Property Value

TypeDescription
RenderFragment<TagBoxGroupHeaderDisplayTemplateContext>

The template content.

|

Remarks

Use the GroupHeaderDisplayTemplate property to customize content displayed in TagBox’s group headers when data items are grouped. The template’s context parameter contains the DisplayText property that allows you to get the header’s display text.

The following code organizes data items into groups based on the Country data source field and customizes displayed text for group headers:

razor
@inject NwindDataService NwindDataService

<DxTagBox Data="@Data"
          @bind-Values="@Values"
          TextFieldName="@nameof(Customer.ContactName)"
          GroupFieldName="@nameof(Customer.Country)"
          SearchMode="@ListSearchMode.AutoSearch"
          SearchFilterCondition="@ListSearchFilterCondition.Contains"
          InputId="tbGrouping">
   <GroupHeaderDisplayTemplate>
        Country: @context.DisplayText
    </GroupHeaderDisplayTemplate>
</DxTagBox>

@code {
    IEnumerable<Customer> Data { get; set; }
    IEnumerable<Customer> Values { get; set; }
    protected override async Task OnInitializedAsync() {
        Data = await NwindDataService.GetCustomersAsync();
        Values = Data.Where(x => x.Country == "Argentina").Take(1);
    }
}
csharp
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace BlazorDemo.Data.Northwind {
    public partial class Customer {
        public Customer() {
            Orders = new HashSet<Order>();
        }
        public string CustomerId { get; set; }
        public string CompanyName { get; set; }
        public string ContactName { get; set; }
        public string ContactTitle { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string Region { get; set; }
        public string PostalCode { get; set; }
        public string Country { get; set; }
        public string Phone { get; set; }
        public string Fax { get; set; }
        public virtual ICollection<Order> Orders { get; set; }
    }
}
csharp
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BlazorDemo.Data.Northwind;
using BlazorDemo.DataProviders;

namespace BlazorDemo.Services {
    public partial class NwindDataService {
        public Task<IEnumerable<Customer>> GetCustomersAsync(CancellationToken ct = default) {
            // Return your data here
        }
    }
}
csharp
using BlazorDemo.Services;
using Microsoft.Extensions.DependencyInjection;

public class Startup {
    public void ConfigureServices(IServiceCollection services) {
        // ...
        services.AddScoped<NwindDataService>();
    }
}

See Also

DxTagBox<TData, TValue> Class

DxTagBox<TData, TValue> Members

DevExpress.Blazor Namespace