Back to Devexpress

DxTagBox<TData, TValue>.ColumnCellDisplayTemplate Property

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

latest4.2 KB
Original Source

DxTagBox<TData, TValue>.ColumnCellDisplayTemplate Property

Specifies a template used to display column cells in the TagBox.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public RenderFragment<TagBoxColumnCellDisplayTemplateContext<TData>> ColumnCellDisplayTemplate { get; set; }

Property Value

TypeDescription
RenderFragment<TagBoxColumnCellDisplayTemplateContext<TData>>

The template for column cells.

|

Remarks

The ColumnCellDisplayTemplate property allows you to customize the appearance of every cell in the TagBox control. The template accepts a TagBoxColumnCellDisplayTemplateContext<TData> object as the context parameter. You can use the parameter’s members to:

  • Fetch the associated data item.
  • Get information about a cell.
  • Access the current column object.

Note

The ColumnCellDisplayTemplate property can be used alongside the CellDisplayTemplate property. If both templates are defined, the column-specific CellDisplayTemplate overrides the global ColumnCellDisplayTemplate for cells within that particular column.

The following code snippet customizes the appearance of all cells in a TagBox control.

razor
<DxComboBox Data="Accounting.Profits"
            @bind-Value="AnnualProfit"
            EditFormat="{0} ({5:C})">
    <Columns>
        <DxListEditorColumn FieldName="Year">
            <CellDisplayTemplate>
                <div class="text-left">
                    @context.Value
                </div>
            </CellDisplayTemplate>
        </DxListEditorColumn>
        <DxListEditorColumn FieldName="Q1" />
        <DxListEditorColumn FieldName="Q2" />
        <DxListEditorColumn FieldName="Q3" />
        <DxListEditorColumn FieldName="Q4" />
        <DxListEditorColumn FieldName="Total" />
    </Columns>
    <ColumnCellDisplayTemplate>
        <div class="text-right">
            @($"{context.Value:C}")
        </div>
    </ColumnCellDisplayTemplate>
</DxComboBox>

@code {
    Profit AnnualProfit { get; set; }
}
csharp
public class Profit(int year, int q1, int q2, int q3, int q4, int total)
{
    public int Year { get; set; } = year;
    public int Q1 { get; set; } = q1;
    public int Q2 { get; set; } = q2;
    public int Q3 { get; set; } = q3;
    public int Q4 { get; set; } = q4;
    public int Total { get; set; } = total;
}
csharp
public static class Accounting
{
    public static List<Profit> Profits { get; } = [
        new Profit(2020, 100, 200, 300, 400, 1000),
        new Profit(2021, 150, 250, 350, 450, 1200),
        new Profit(2022, 200, 300, 400, 500, 1400),
        new Profit(2023, 250, 350, 450, 550, 1600),
        new Profit(2024, 300, 400, 500, 600, 1800)
        ];
}
css
.text-right {
    text-align: right;
}
.text-left {
    text-align: left;
}

Run Demo: TagBox - Cell Display Template

Implements

DevExpress.Blazor.ITagBox<TData, TValue>.ColumnCellDisplayTemplate

See Also

DxTagBox<TData, TValue> Class

DxTagBox<TData, TValue> Members

DevExpress.Blazor Namespace