JavaScript/jQuery 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".
Specify the columns.caption property to change the column header text.
JavaScript
- $(function() {
- $("#treeListContainer").dxTreeList({
- // ...
- columns: [
- { dataField: "CompanyName", caption: "Company" },
- // ...
- ]
- });
- });
If you need a more specific customization, define a custom template in the columns.headerCellTemplate property. This property accepts a function or template container.
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>')
- }]
- });
- });
To hide column headers, assign false to the showColumnHeaders property.
JavaScript
- $(function() {
- $("#treeListContainer").dxTreeList({
- // ...
- showColumnHeaders: false
- });
- });
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.