# Multi-Column Headers

The Treelist allows you to stack several columns under one header to visually group relevant fields for your end users.

To use multiple column headers:

1. Define a `TreeListColumn` instance for each multi-column header you want. Set its `Title` or [`HeaderTemplate`](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/column-header).
2. Under its `<Columns>` nested tag, add the columns you want it to contain.

While you can set all the parameters of such a multi-column header column, it only supports and works with the `Title`, and the nested `HeaderTemplate` and `Columns` tags (templates).

You will find the following sections in this article:

* [Basic Example](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#basic-example)
* [Behavior With Other Features](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#behavior-with-other-features)

## Basic Example

The following code snippet shows how you can group columns in the Treelist in multi-column headers. You can also use "regular" columns at the root level, not all of them have to be column groups.

> caption Multiple Column Headers in the Treelist

<demo metaUrl="client/treelist/columns/multi-column-headers/example-1/" height="720"></demo>

## Behavior With Other Features

This section explains how using multi column headers changes behaviors of other component functionalities or how certain features behave with multi-column headers. If a feature is not listed, it is not affected.

* [Width](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#width)
* [Sorting, Filtering, Grouping, Editing](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#sorting-filtering-grouping-editing)
* [Resizing](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#resizing)
* [Reordering](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#reordering)
* [Column Menu](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#column-menu)
* [State Management](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#state-management)
* [Locked columns](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#locked-columns)
* [Keyboard navigation](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers#keyboard-navigation)

### Width

The `Width` paramter of a multi-column header is ignored, its width depends on the sum of the widths for its child columns.

### Sorting, Filtering, Grouping, Editing

These functionalities do not work on a multi-column header column, but only on the actual child columns.

The column used for the multiple column header serves for presentation purposes only. It does not use the `Field` parameter and cannot perform data source operations such as filtering, sorting, grouping, editing, because they would span several fields and that is not possible.

Individual columns under a shared group header can be sorted, filtered, grouped and edited as usual.

### Resizing

Multi-column headers can be resized and resizing is similar to standard columns.

Individual columns under a shared group header can be resized as well.

The `Resizable` parameter is honored for both individual columns and column group headers.

### Reordering

Column reordering works according to the following rules:

* Root multi-header columns can be reordered with other root multi-header columns.
  * Reordering a group of columns moves all its child columns as well.
* Individual columns can be reordered within their parent group only.
  * Child columns of different parent columns (and/or on different levels) cannot be reordered.

The `Reordable` parameter is honored for both individual columns and column group headers.

### Column Menu

A multi-header column does not show up in the list of columns in the column chooser of individual columns from the last level. If you hide all child columns, the parent column will also hide.

### State Management

The state of a multi-header column is handled in the same way as a standard column. The columns in the state are listed in a flat list in the order of definition. For example, for the following setup:

```RAZOR.skip-repl
<TelerikGrid>
    <GridColumns>
        <GridColumn Title="column 1">
            <Columns>
                <GridColumn Title="column 1.1" />
                <GridColumn Title="column 1.2" />
            </Columns>
        </GridColumn>

        <GridColumn Title="column 2"></GridColumn>
    </GridColumns>
</TelerikGrid>
```

The State will be:

| Column state index | Column     |
| ------------------ | ---------- |
| 0                  | column 1   |
| 1                  | column 1.1 |
| 2                  | column 1.2 |
| 3                  | column 2   |

Note that this order is different than the order in which the blazor framework initializes the column components, its goal is to be similar to a human-readable order that matches the column definition.

### Locked columns

You can lock an entire multi-column header through its `Locked` parameter. Doing so will lock all its child columns.

Therefore, we advise that you do not set `Locked=false` for child columns of locked parent columns, and you can consider setting `Lockable=false` on them to prevent the user from unpinning them and getting sub-optimal layout. Setting `Locked=true` for a child column is not supported.

### Keyboard navigation

The keyboard navigation in the multi-column headers follows the functionality of Excel.

## See Also

* [Live Demo: Multi-Column Headers](https://demos.telerik.com/blazor-ui/treelist/multi-column-headers)
