# Blazor TreeList Component Overview

The <a href="https://www.telerik.com/blazor-ui/treelist" target="_blank">Blazor TreeList component</a> displays hierarchical data in a tabular format and allows [sorting](https://www.telerik.com/blazor-ui/documentation/components/treelist/sorting), [filtering](https://www.telerik.com/blazor-ui/documentation/components/treelist/filter/overview), and [data editing](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview). It also provides item [selection](https://www.telerik.com/blazor-ui/documentation/components/treelist/selection/overview), [templates](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/overview), and [load on demand](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/load-on-demand).

## Creating Blazor TreeList

The TreeList supports both flat data and hierarchical data. The example below uses flat data.

1. Use the `<TelerikTreeList>` tag.
2. Assign the TreeList `Data` attribute to an `IEnumerable<TItem>` property. The model class `TItem` should have two properties that describe the parent-child relations, for example: `Id` (`int`) and `ParentId` (`int?`).
3. Set the following TreeList parameters, based on the `TItem` property names: `IdField` and `ParentIdField`.
4. Add some `<TreeListColumn>` instances inside a `<TreeListColumns>` tag.
5. For each column, set a `Field` and an optional `Title`.
6. Set `Expandable="true"` for the column that should render expand/collapse arrows.
7. (optional) Enable other features, such as `Pageable`, `Sortable` or `FilterMode`.

> caption Basic TreeList

<demo metaUrl="client/treelist/overview/example-1/" height="720"></demo>

## Data Binding

The Telerik Blazor TreeList is datasource agnostic. You can use any database and service, according to your project. The important step is to configure the model property names, which define the data structure.

The following resources provide details and examples for data binding a TreeList:

* [TreeList Data Binding Overview](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/overview) - general information on how data binding works
* [Bind TreeList to Flat Self-Referencing Data](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/flat-data)
* [Bind TreeList to Hierarchical Data](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/hierarchical-data) - in this case, each data item may contain a nested item collection
* [Load On Demand in TreeList](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/load-on-demand) - how to load child items only when necessary

## Data Operations

The Blazor TreeList supports all fundamental data operations out-of-the-box:

* [TreeList Paging](https://www.telerik.com/blazor-ui/documentation/components/treelist/paging)
* [TreeList Sorting](https://www.telerik.com/blazor-ui/documentation/components/treelist/sorting)
* [TreeList Filtering](https://www.telerik.com/blazor-ui/documentation/components/treelist/filter/overview)

## Editing

The TreeList can perform CRUD operations on its current data. It exposes events that let you control the operations and transfer changes to the actual data source. See [TreeList CRUD Operations Overview](https://www.telerik.com/blazor-ui/documentation/components/treelist/editing/overview) for more details.

## Column Features

The Treelist columns are one of its main building blocks. They offer a rich set of functionality to enable flexibility for different application scenarios.

* [Bound Columns](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/bound)
* [Column display Format](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/display-format) for numeric and date values
* [Column reordering](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/reorder)
* [Column resizing](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/resize)
* [Column Menu](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/menu) to control data operations and column visibility
* [How column width works](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/width)
* [CheckBox column](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/checkbox)
* [Command column](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/command)
* [Frozen (Locked) columns](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/frozen)
* [UI Virtualization](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/virtual)
* [Visibility](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/visible)
* [Autogenerated columns](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/auto-generated)
* [Multi-column Headers](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/multi-column-headers)
* [Column events](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/events)

## Templates

The various [TreeList templates](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/overview) provide better control over the rendering of:

* [data cells](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/column) and [data rows](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/row)
* [header cells](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/column-header)
* [filter menus and rows](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/filter)
* [data editors](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/editor)
* [no data message](https://www.telerik.com/blazor-ui/documentation/components/treelist/templates/no-data-template)

## More TreeList Features

* [Selection - single and multiple](https://www.telerik.com/blazor-ui/documentation/components/treelist/selection/overview).
* [State - get or set the TreeList configuration programmatically](https://www.telerik.com/blazor-ui/documentation/components/treelist/state)
* [Toolbar - define custom TreeList actions](https://www.telerik.com/blazor-ui/documentation/components/treelist/toolbar)
* [Export](https://www.telerik.com/blazor-ui/documentation/components/treelist/export/overview)

## TreeList Parameters

The following table lists Tree List parameters, which are not related to other features on this page. Check the [TreeList API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.teleriktreelist-1) for a full list of properties, methods and events.

<style>
    .article table {
        table-layout: auto;
        word-break: normal;
    }
</style>

| Parameter   | Type and Default Value | Description                                                                                                                                                                                                                                                                                                                                                          |
| ----------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Class`     | `string`               | The additional CSS class that will be rendered to the `div.k-treelist` element. Use it to apply custom styles or [override the theme](https://www.telerik.com/blazor-ui/documentation/styling-and-themes/override-theme-styles). For example, [change the TreeList font size](https://www.telerik.com/blazor-ui/documentation/knowledge-base/grid-change-font-size). |
| `Height`    | `string`               | The height value in [any supported CSS unit](https://www.telerik.com/blazor-ui/documentation/common-features/dimensions).                                                                                                                                                                                                                                            |
| `Navigable` | `bool`                 | Whether [keyboard navigation](https://www.telerik.com/blazor-ui/documentation/accessibility/overview#keyboard-navigation) is enabled.                                                                                                                                                                                                                                |
| `Width`     | `string`               | The width value in [any supported CSS unit](https://www.telerik.com/blazor-ui/documentation/common-features/dimensions). The TreeList has no default width, but expands horizontally to fill its container.                                                                                                                                                          |

## TreeList Reference and Methods

The TreeList component has methods to execute actions such as:

* [Rebind to refresh the data](https://www.telerik.com/blazor-ui/documentation/components/treelist/refresh-data#rebind-method)
* [Automatically resize columns to fit their content](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/resize)
* [Get or set the TreeList configuration state](https://www.telerik.com/blazor-ui/documentation/components/treelist/state)
* [Get the dragged data item and its drop index from the destination TreeList](https://www.telerik.com/blazor-ui/documentation/components/treelist/row-drag-drop)

To execute these methods, obtain a reference to the TreeList instance via `@ref`.

The TreeList is a generic component. Its type depends on the type of its model and the type of its `Value`. In case you cannot provide either the `Value` or `Data` initially, you need to [set the corresponding types to the `TItem` and `TValue` parameters](https://www.telerik.com/blazor-ui/documentation/common-features/data-binding/overview#component-type).

> caption Store the TreeList instance reference and execute methods

<demo metaUrl="client/treelist/overview/example-2/" height="720"></demo>

# Next Steps

* [Explore Tree List data binding](https://www.telerik.com/blazor-ui/documentation/components/treelist/data-binding/overview)
* [Learn about Tree List columns](https://www.telerik.com/blazor-ui/documentation/components/treelist/columns/bound)

## See Also

* [Live Demos: TreeList](https://demos.telerik.com/blazor-ui/treelist/overview)
* [TreeList API Reference](https://www.telerik.com/blazor-ui/documentation/api/telerik.blazor.components.teleriktreelist-1)
