Angular TreeList - Customize Column Headers

The TreeList generates column headers based on the names of data fields by default. For example, if a data field is "fullName", the column header text is "Full Name".

DevExtreme HTML5 JavaScript jQuery Angular Knockout UI component TreeList ColumnHeaders

Specify the columns.caption property to change the column header text.

jQuery
JavaScript
$(function() {
    $("#treeListContainer").dxTreeList({
        // ...
        columns: [
            { dataField: "CompanyName", caption: "Company" },
            // ...
        ]
    });
});
Angular
HTML
TypeScript
<dx-tree-list ... >
    <dxi-column dataField="CompanyName" caption="Company"></dxi-column>
</dx-tree-list>
import { DxTreeListModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})

If you need a more specific customization, define a custom template in the columns.headerCellTemplate property. This property accepts a function or template container.

jQuery
JavaScript
$(function() {
    $("#treeListContainer").dxTreeList({
        // ...
        columns: [{
            dataField: "Title",
            caption: "Position",
            headerCellTemplate: function (header, info) {
                $('<div>')
                    .html(info.column.caption)
                    .css('font-size', '16px')
                    .appendTo(header);
            }
        }, {
            dataField: "Address",
            headerCellTemplate: $('<i style="color: black">Mailing Address</i>')
        }]
    });
 });
Angular
HTML
TypeScript
<dx-tree-list ... >
    <dxi-column
        dataField="Title"
        caption="Position"
        headerCellTemplate="titleHeaderTemplate">
    </dxi-column>
    <dxi-column
        dataField="Address"
        headerCellTemplate="addressHeaderTemplate">
    </dxi-column>
    <div *dxTemplate="let info of 'titleHeaderTemplate'">
        <p style="font-size:16px">{{info.column.caption}}</p>
    </div>
    <div *dxTemplate="let info of 'addressHeaderTemplate'">
        <i style="color: black">Mailing Address</i>
    </div>
</dx-tree-list>
import { DxTreeListModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})

To hide column headers, assign false to the showColumnHeaders property.

jQuery
JavaScript
$(function() {
    $("#treeListContainer").dxTreeList({
        // ...
        showColumnHeaders: false
    });
 });
Angular
HTML
TypeScript
<dx-tree-list ...
    [showColumnHeaders]="false">
</dx-tree-list>
import { DxTreeListModule } from "devextreme-angular";
// ...
export class AppComponent {
    // ...
}
@NgModule({
    imports: [
        // ...
        DxTreeListModule
    ],
    // ...
})
See Also