Introducing Syncfusion’s new Angular TreeGrid Component | Syncfusion Blogs
Live Chat Icon For mobile
Live Chat Icon
Popular Categories.NET  (179).NET Core  (28).NET MAUI  (215)Angular  (112)ASP.NET  (51)ASP.NET Core  (83)ASP.NET MVC  (90)Azure  (41)Black Friday Deal  (1)Blazor  (228)BoldSign  (15)DocIO  (24)Essential JS 2  (109)Essential Studio  (200)File Formats  (69)Flutter  (133)JavaScript  (226)Microsoft  (120)PDF  (82)Python  (1)React  (105)Streamlit  (1)Succinctly series  (131)Syncfusion  (948)TypeScript  (33)Uno Platform  (3)UWP  (3)Vue  (45)Webinar  (52)Windows Forms  (61)WinUI  (71)WPF  (163)Xamarin  (160)XlsIO  (38)Other CategoriesBarcode  (5)BI  (29)Bold BI  (8)Bold Reports  (2)Build conference  (9)Business intelligence  (55)Button  (4)C#  (158)Chart  (141)Chart of the week  (55)Cloud  (15)Company  (443)Dashboard  (8)Data Science  (3)Data Validation  (8)DataGrid  (70)Development  (662)Doc  (8)DockingManager  (1)eBook  (99)Enterprise  (22)Entity Framework  (7)Essential Tools  (14)Excel  (43)Extensions  (23)File Manager  (7)Gantt  (19)Gauge  (12)Git  (5)Grid  (31)HTML  (13)Installer  (2)Knockout  (2)Language  (1)LINQPad  (1)Linux  (2)M-Commerce  (1)Metro Studio  (11)Mobile  (513)Mobile MVC  (9)OLAP server  (1)Open source  (1)Orubase  (12)Partners  (21)PDF viewer  (43)Performance  (13)PHP  (2)PivotGrid  (5)Predictive Analytics  (6)Report Server  (3)Reporting  (10)Reporting / Back Office  (11)Rich Text Editor  (12)Road Map  (12)Scheduler  (54)Security  (4)SfDataGrid  (9)Silverlight  (21)Sneak Peek  (31)Solution Services  (4)Spreadsheet  (11)SQL  (14)Stock Chart  (1)Surface  (4)Tablets  (5)Theme  (12)Tips and Tricks  (113)UI  (393)Uncategorized  (68)Unix  (2)User interface  (68)Visual State Manager  (2)Visual Studio  (31)Visual Studio Code  (19)Web  (619)What's new  (334)Windows 8  (19)Windows App  (2)Windows Phone  (15)Windows Phone 7  (9)WinRT  (26)
Angular Treegrid

Introducing Syncfusion’s new Angular TreeGrid Component

Syncfusion is excited to announce yet another value-added control in the form of the TreeGrid in Syncfusion’s Essential JS 2 (WEB) platform. The TreeGrid visualizes self-referential and hierarchical data effectively in a tabular format. Normally we go with DataGrid to visualize hierarchy data. But in data grid, columns would be different for parent and child data. As an alternative, we offer the TreeGrid where you can have same the columns in tabular representation for hierarchical or self-referential data.

Expand/Collapse icons will appear in one of the columns to expand and collapse child rows. And icons are customizable in treegrid and in-fact you can customize the whole CSS of TreeGrid.

Where to use TreeGrid?

TreeGrid is best for use in things like Library books management, assets management, employee details with designation hierarchy, and more.

As you look into those areas, you may find that hierarchy is the common key in all of them. And yes, treegrid is most likely used in places with hierarchy relationships.

Key Features

Not just a visual representation, TreeGrid comes with most requested features with best-in-class UI. Following are some of the features we have included and you can check out each and every one of them in our demo.

  • Column customizations such as template, resize, reorder, and column menu.
  • Cell Editing and other built-in edit modes such as row and dialog editing.
  • Sorting, filtering, searching, and paging actions for better viewing of data.
  • Export to Excel, CSV, PDF, and print to hard copy.

How to use TreeGrid?

Here we will explain how to use TreeGrid in Angular platform. For other platforms, kindly refer to the following documentations:

  1. TypeScript
  2. JavaScript
  3. React
  4. Vue
  5. ASP.NET Core

Start a new Angular application using the Angular CLI command as follows.

ng new my-app
cd my-app

All Syncfusion packages are published in the registry. You can just as easily install TreeGrid dependencies using the following command:

npm install @syncfusion/ej2-angular-treegrid --save

The next step is to register the TreeGrid module and CSS Reference.

Registering TreeGrid Module

Import the TreeGrid module into the Angular application(app.module.ts) from the package @syncfusion/ej2-angular-treegrid [src/app/app.module.ts].

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
// Add TreeGridModule for the TreeGrid component
import { TreeGridModule} from '@syncfusion/ej2-angular-treegrid';
import { AppComponent }  from './app.component';

//declaration of ej2-angular-treegrid module into NgModule
imports: [ BrowserModule, TreeGridModule ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
export class AppModule { }

Adding CSS reference

The following CSS files are available in the ../node_modules/@syncfusion package folder. This can be referenced in [src/styles.css] using the following code.

@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-calendars/styles/material.css';
@import '../node_modules/@syncfusion/ej2-dropdowns/styles/material.css';
@import '../node_modules/@syncfusion/ej2-inputs/styles/material.css';
@import '../node_modules/@syncfusion/ej2-navigations/styles/material.css';
@import '../node_modules/@syncfusion/ej2-popups/styles/material.css';
@import '../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css';
@import '../node_modules/@syncfusion/ej2-grids/styles/material.css';
@import '../node_modules/@syncfusion/ej2-treegrid/styles/material.css';

With all the required packages installed and referred, it’s time to add the TreeGrid component to the application.

Modify the template in the [src/app/app.component.ts] file to render the TreeGrid component. Add the Angular TreeGrid by using the <ejs-treegrid> selector in the template section of the app.component.ts file.

For TreeGrid to show something, we need to provide data to it by using the dataSource property. For child data mapping, the childMapping property is used.

Now we have reached the minimal configurations required to render TreeGrid. Refer to the following code snippet.

import { Component, OnInit } from '@angular/core';
import { sampleData } from './datasource';

selector: 'app-container',
template: `<ejs-treegrid [dataSource]='data' childMapping='subtasks‘> </ejs-treegrid>`
export class AppComponent implements OnInit {

public data: Object[];

ngOnInit(): void { = sampleData;

By default, the first column would be the tree column, which holds the expand/collapse icon to expand/collapse the child row. The treeColumnIndex property changes the tree column.

Also columns are customizable using the ‘e-columns’ selector of TreeGrid.

import { Component, OnInit } from '@angular/core';
import { sampleData } from './datasource';

selector: 'app-container',
template: `<ejs-treegrid [dataSource]='data' [treeColumnIndex]='1' childMapping='subtasks' height="350">
               <e-column field='taskID' headerText='Task ID' textAlign='Right' width=70></e-column>                    
               <e-column field='taskName' headerText='Task Name' textAlign='Left' width=200></e-column>                    
               <e-column field='startDate' headerText='Start Date' textAlign='Right' format='yMd' width=90></e-column>                    
               <e-column field='duration' headerText='Duration' textAlign='Right' width=80></e-column>                
export class AppComponent implements OnInit {

public data: Object[];

ngOnInit(): void { = sampleData;


And the final appearance of TreeGrid would be as follows.

Note: To create TreeGrid with additional features, inject the required modules. Refer here for more details.


If you would like to try the TreeGrid component, you can download our free trial. You can visit the treegrid sample source in GitHub, and you can check our sample browser and documentation for detailed explanations and the facts you need to proceed further.

We hope that you like the TreeGrid component, and we look forward to you trying it out in the 2018 Volume 4 release. You can find the 2018 Volume 4 install download link here. Please feel free to leave your feedback in the comments section below.

If you like this blog post, we think you’ll also like the following free e-books!


Share this post:

Popular Now

Be the first to get updates

Subscribe RSS feed

Be the first to get updates

Subscribe RSS feed