---
product: "AG Grid"
title: "Tree Data - Overview"
description: "Tree Data provides a way to supply the grid with structured hierarchical data."
enterprise: true
framework: javascript
version: "36.2.0"
related:
    - title: "Supplying Data"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/tree-data-data/"
    - title: "Group Column"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/tree-data-group-column/"
    - title: "Expanding Groups"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/tree-data-opening-groups/"
    - title: "Tree Selection"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/tree-data-selection/"
    - title: "Filtering"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/tree-data-filtering/"
    - title: "Tree Row Dragging"
      url: "https://www.ag-grid.com/archive/36.2.0/javascript-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 {
  ClientSideRowModelModule,
  GridApi,
  GridOptions,
  ModuleRegistry,
  createGrid,
  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]);

let gridApi: GridApi;

const gridOptions: GridOptions = {
  columnDefs: [
    { 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: {
    flex: 1,
  },
  autoGroupColumnDef: {
    headerName: "File Explorer",
    minWidth: 280,

    cellRendererParams: {
      suppressCount: true,
    },
  },
  rowData: getData(),
  treeData: true,
  groupDefaultExpanded: -1,
  getDataPath: (data) => data.path,
};

// wait for the document to be loaded, otherwise
// AG Grid will not find the div in the document.
// lookup the container we want the Grid to use
const gridDiv = document.querySelector<HTMLElement>("#myGrid")!;

// create the grid passing in the div to use together with the columns & data we want to use
gridApi = createGrid(gridDiv, gridOptions);
```

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

## 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/javascript-data-grid/tree-data-paths/). Alternatively, see how to [Provide Tree Data](https://www.ag-grid.com/archive/36.2.0/javascript-data-grid/tree-data-data/).

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

```js
const gridOptions = {
    treeData: true,
    getDataPath: data => data.path,

    // other grid options ...
}
```

## 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` |  |  |  |
