How can I help you?
Getting Started With Angular TreeGrid Component
27 May 20267 minutes to read
This section outlines the steps required to create an Essential® JS 2 TreeGrid and demonstrates basic usage of the Angular TreeGrid control within an Angular CLI application.
Note: This guide supports Angular 21 and other recent Angular versions. For detailed compatibility with other Angular versions, please refer to the Angular version support matrix. Starting from Angular 19, standalone components are the default, and this guide reflects that architecture.
To get started quickly with the Angular TreeGrid using CLI and Schematics, refer to the following video:
Setup Angular environment
Use the Angular CLI to set up Angular applications. To install Angular CLI, execute:
npm install -g @angular/cliAngular 21 Standalone Architecture: Standalone components are the default in Angular 21. This guide uses the modern standalone architecture. For more information about the standalone architecture, refer to the Standalone Guide.
Installing a specific version
To install a particular version of Angular CLI, use:
npm install -g @angular/[email protected]Create a new application
With Angular CLI installed, execute this command to generate a new application:
ng new syncfusion-angular-app- This command will prompt to configure settings like enabling Angular routing and choosing a stylesheet format.
? Which stylesheet format would you like to use? (Use arrow keys)
> CSS [ https://developer.mozilla.org/docs/Web/CSS ]
Sass (SCSS) [ https://sass-lang.com/documentation/syntax#scss ]
Sass (Indented) [ https://sass-lang.com/documentation/syntax#the-indented-syntax ]
Less [ http://lesscss.org ]- By default, a CSS-based application is created. Use SCSS if required:
ng new syncfusion-angular-app --style=scss- During project setup, when prompted for the Server-side rendering (SSR) option, choose the appropriate configuration.

- Select the required AI tool or ‘none’ if you do not need any AI tool.

- Navigate to your newly created application directory:
cd syncfusion-angular-appNote: In Angular 19 and below, it uses
app.component.ts,app.component.html,app.component.cssetc. In Angular 20+, the CLI generates a simpler structure withsrc/app/app.ts,app.html, andapp.css(no.component.suffixes).
Adding Syncfusion® Angular TreeGrid packages
To install the TreeGrid component, use the following command:
npm install @syncfusion/ej2-angular-treegrid --saveAdding CSS reference
The following CSS files are available in the ../node_modules/@syncfusion package folder. Add these as references in src/styles.css
@import '../node_modules/@syncfusion/ej2-base/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-calendars/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-grids/styles/material3.css';
@import '../node_modules/@syncfusion/ej2-angular-treegrid/styles/material3.css';For using SCSS styles, refer to this guide.
Add TreeGrid component
Modify the template in the src/app/app.ts file to render the treegrid component. Add the Angular TreeGrid by using <ejs-treegrid> selector in template section of the app.ts file.
import { TreeGridModule } from '@syncfusion/ej2-angular-treegrid'
import { Component } from '@angular/core';
// Defines the data to be displayed in the TreeGrid.
const data: object[] = [
{
TaskID: 1, TaskName: 'Planning', StartDate: new Date('02/04/2025'), EndDate: new Date('02/07/2025'), Duration: 4,
subtasks: [
{ TaskID: 2, TaskName: 'Plan timeline', StartDate: new Date('02/04/2025'), EndDate: new Date('02/07/2025'), Duration: 4, },
{ TaskID: 3, TaskName: 'Plan budget', StartDate: new Date('02/04/2025'), EndDate: new Date('02/07/2025'), Duration: 4, },
],
},
{
TaskID: 4, TaskName: 'Design', StartDate: new Date('02/10/2025'), EndDate: new Date('02/14/2025'), Duration: 5,
subtasks: [
{ TaskID: 5, TaskName: 'Software Specification', StartDate: new Date('02/10/2025'), EndDate: new Date('02/12/2025'), Duration: 3, },
{ TaskID: 6, TaskName: 'Design Documentation', StartDate: new Date('02/13/2025'), EndDate: new Date('02/14/2025'), Duration: 2, },
{ TaskID: 7, TaskName: 'Design complete', StartDate: new Date('02/14/2025'), EndDate: new Date('02/14/2025'), Duration: 1 },
],
},
];
@Component({
imports: [TreeGridModule],
standalone: true,
selector: 'app-root',
template: `
<!-- Assigns the dataset to the TreeGrid component -->
<ejs-treegrid [dataSource]='data' [treeColumnIndex]='1' childMapping='subtasks'>
<!-- Define the columns to be displayed -->
<e-columns>
<e-column field='TaskID' headerText='Task ID' textAlign='Right' width=70></e-column>
<e-column field='TaskName' headerText='Task Name' textAlign='Left' width=120></e-column>
<e-column field='StartDate' headerText='Start Date' textAlign='Right' format='yMd' width=90></e-column>
<e-column field='EndDate' headerText='End Date' textAlign='Right' format='yMd' width=90></e-column>
<e-column field='Duration' headerText='Duration' textAlign='Right' width=80></e-column>
</e-columns>
</ejs-treegrid>
`
})
export class App {
public data: object[] = data;
}import { bootstrapApplication } from '@angular/platform-browser';
import { appConfig } from './app/app.config';
import { App } from './app/app';
bootstrapApplication(App, appConfig)
.catch((err) => console.error(err));Run the application
ng serve --openSee also
- Grid Feature Modules
- Getting Started with JavaScript documentation
- Getting Started with JavaScript (ES5) documentation
- Getting Started with React documentation
- Getting Started with Vue documentation
- Getting Started with ASP.NET Core documentation
- Getting Started with ASP.NET MVC documentation
- Getting Started with Blazor documentation