---
product: "AG Grid"
title: "Tree Data - Overview"
description: "Tree Data provides a way to supply the grid with structured hierarchical data."
enterprise: true
framework: angular
version: "36.2.0"
related:
    - title: "Supplying Data"
      url: "https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-data/"
    - title: "Group Column"
      url: "https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-group-column/"
    - title: "Expanding Groups"
      url: "https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-opening-groups/"
    - title: "Tree Selection"
      url: "https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-selection/"
    - title: "Filtering"
      url: "https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-filtering/"
    - title: "Tree Row Dragging"
      url: "https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-row-dragging/"
llms: "https://www.ag-grid.com/archive/36.2.0/llms.txt"
---

# Tree Data - Overview

Tree Data provides a way to supply the grid with structured hierarchical data.

#### Kitchen Sink

```ts
import { Component } from "@angular/core";
import { AgGridAngular } from "ag-grid-angular";
import {
  AutoGroupColumnDef,
  ClientSideRowModelModule,
  ColDef,
  ColGroupDef,
  GetDataPath,
  GridApi,
  GridOptions,
  GridReadyEvent,
  ModuleRegistry,
  enableDevValidations,
} from "ag-grid-community";
import { TreeDataModule } from "ag-grid-enterprise";
import { getData } from "./data";

if (process.env.NODE_ENV !== "production") {
  // Enable extended validations only for development
  enableDevValidations();
}

ModuleRegistry.registerModules([ClientSideRowModelModule, TreeDataModule]);

@Component({
  selector: "my-app",
  standalone: true,
  imports: [AgGridAngular],
  template: `<ag-grid-angular
    style="width: 100%; height: 100%;"
    [columnDefs]="columnDefs"
    [defaultColDef]="defaultColDef"
    [autoGroupColumnDef]="autoGroupColumnDef"
    [rowData]="rowData"
    [treeData]="true"
    [groupDefaultExpanded]="groupDefaultExpanded"
    [getDataPath]="getDataPath"
  /> `,
})
export class AppComponent {
  columnDefs: ColDef[] = [
    { field: "created" },
    { field: "modified" },
    {
      field: "size",
      aggFunc: "sum",
      valueFormatter: (params) => {
        if (params.value == null) {
          return ""; // params.value can be null/undefined here (e.g. no size for this row)
        }
        const sizeInKb = params.value / 1024;
        if (sizeInKb > 1024) {
          return `${+(sizeInKb / 1024).toFixed(2)} MB`;
        } else {
          return `${+sizeInKb.toFixed(2)} KB`;
        }
      },
    },
  ];
  defaultColDef: ColDef = {
    flex: 1,
  };
  autoGroupColumnDef: AutoGroupColumnDef = {
    headerName: "File Explorer",
    minWidth: 280,
    cellRendererParams: {
      suppressCount: true,
    },
  };
  rowData: any[] | null = getData();
  groupDefaultExpanded = -1;
  getDataPath: GetDataPath = (data) => data.path;
}
```

[Live example: Kitchen Sink](https://www.ag-grid.com/archive/36.2.0/examples/tree-data/kitchen-sink/angular/)

## Enabling Tree Data

To enable Tree Data set the `treeData` property to `true` in the grid options, and provide a `getDataPath` callback to configure the [Row Hierarchy](https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-paths/). Alternatively, see how to [Provide Tree Data](https://www.ag-grid.com/archive/36.2.0/angular-data-grid/tree-data-data/).

The example above uses the following configuration to enable Tree Data:

```ts
<ag-grid-angular
    [treeData]="treeData"
    [getDataPath]="getDataPath"
    /* other grid options ... */ />

this.treeData = true;
this.getDataPath = data => data.path;
```

## API Reference

| Property | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `treeData` | `boolean` |  |  |  |
| `getDataPath` | `GetDataPath` |  |  |  |
| `treeDataChildrenField` | `string` |  |  |  |
| `treeDataParentIdField` | `string` |  |  |  |
| `treeDataDisplayType` | `TreeDataDisplayType` |  |  |  |
| `autoGroupColumnDef` | `AutoGroupColumnDef` |  |  |  |
| `groupDefaultExpanded` | `number` |  |  |  |
| `isGroupOpenByDefault` | `IsGroupOpenByDefault` |  |  |  |
| `suppressGroupRowsSticky` | `boolean` |  |  |  |
| `stickyRowsMaxViewportRatio` | `number` |  |  |  |
