Skip to main content
All docs
V24.1

DxTreeList.DataColumnCellDisplayTemplate Property

Specifies a common template used to display all data column cells in the TreeList.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

[Parameter]
public RenderFragment<TreeListDataColumnCellDisplayTemplateContext> DataColumnCellDisplayTemplate { get; set; }

Property Value

Type Description
RenderFragment<TreeListDataColumnCellDisplayTemplateContext>

Template content.

Remarks

The DataColumnCellDisplayTemplate allows you to specify custom content and change the appearance of cells in all TreeList data columns. To define a template for individual TreeList data columns, use the DxTreeListDataColumn.CellDisplayTemplate.

The DataColumnCellDisplayTemplate accepts a TreeListDataColumnCellDisplayTemplateContext object as the context parameter. You can use the parameter’s members to get information about a column cell (DataColumn, Value, DisplayText, VisibleIndex). You can also access the TreeList object and use its members to obtain additional information about the TreeList.

The following example customizes appearance of column cells to distinguish between odd and even rows:

@inject EmployeeTaskService EmployeeTaskService

<style>
    .my-style {
        color: blue;
        font-weight: bold;
    }
    .my-date-style {
        color: mediumblue;
        font-weight: bold;
    }
</style>

<DxTreeList Data="TreeListData" KeyFieldName="Id" ParentKeyFieldName="ParentId">
    <Columns>
        <DxTreeListDataColumn FieldName="Name" Caption="Task" />
        <DxTreeListDataColumn FieldName="EmployeeName" />
        <DxTreeListDataColumn FieldName="StartDate" />
        <DxTreeListDataColumn FieldName="DueDate" />
    </Columns>
    <DataColumnCellDisplayTemplate>
        @{
            if (context.VisibleIndex % 2 == 1) {
                if (context.DataColumn.FieldName.Contains("Date")) {
                    <span class="my-date-style">@context.DisplayText</span>
                }
                else {
                    <span class="my-style">@context.DisplayText</span>
                }
            }
            else {
                <span>@context.DisplayText</span>
            }
        }
    </DataColumnCellDisplayTemplate>
</DxTreeList>

@code {
    List<EmployeeTask> TreeListData { get; set; }

    protected override void OnInitialized() {
        TreeListData = EmployeeTaskService.GenerateData();
    }
}

Blazor TreeList Column Cell Display Template

For more information about templates in the TreeList component, refer to the following topic: Templates in Blazor TreeList.

See Also