Angular UI Components Documentation
The Angular Tree shows a hierarchical collection of items, with check boxes, drag-and-drop and load-on-demand. This guide adds the Angular Tree (jqxTree) to an app, then shows how to set its options, handle its events and call its methods.
jqwidgets-ngjqwidgets-ng/jqxtree 
In an Angular project (to start one, see Getting started with Angular), add the package with the Angular CLI. It asks for a theme and adds the styles to angular.json:
ng add jqwidgets-ng
Components are standalone: add jqxTreeModule to the imports of the component that uses it.
import { Component } from '@angular/core';
import { jqxTreeModule } from 'jqwidgets-ng/jqxtree';
@Component({
selector: 'app-root',
imports: [jqxTreeModule],
templateUrl: './app.html'
})
export class App {}
The source of the live Default Functionality demo.
<jqxExpander [width]="300" [height]="400"
[showArrow]="false" [toggleMode]="'none'">
<div>
Folders
</div>
<div style="overflow: hidden;">
<jqxTree #treeReference
[width]="'100%'" [height]="'100%'" [source]="treeSource">
</jqxTree>
</div>
</jqxExpander>
import { Component, AfterViewInit, ViewEncapsulation, viewChild } from '@angular/core';
import { jqxTreeComponent } from 'jqwidgets-ng/jqxtree';
import { jqxDropDownButtonComponent } from 'jqwidgets-ng/jqxdropdownbutton';
import { CommonModule } from '@angular/common';
import { jqxTreeModule } from 'jqwidgets-ng/jqxtree';
import { jqxExpanderModule } from 'jqwidgets-ng/jqxexpander';
@Component({
imports: [CommonModule, jqxTreeModule, jqxExpanderModule],
selector: 'app-root',
templateUrl: './app.html',
styleUrl: './app.css',
encapsulation: ViewEncapsulation.None
})
export class App implements AfterViewInit {
readonly tree = viewChild.required<jqxTreeComponent>('treeReference');
ngAfterViewInit(): void {
setTimeout(() => {
this.tree().selectItem(null);
});
}
treeSource: any[] = [
{
icon: 'https://www.jqwidgets.com/angular/images/mailIcon.png',
label: 'Mail',
expanded: true,
items: [
{
icon: 'https://www.jqwidgets.com/angular/images/calendarIcon.png',
label: 'Calendar'
},
{
icon: 'https://www.jqwidgets.com/angular/images/contactsIcon.png',
label: 'Contacts',
selected: true
}
]
},
{
icon: 'https://www.jqwidgets.com/angular/images/folder.png',
label: 'Inbox',
expanded: true,
items: [
{ icon: 'https://www.jqwidgets.com/angular/images/folder.png', label: 'Admin' },
{ icon: 'https://www.jqwidgets.com/angular/images/folder.png', label: 'Corporate' },
{ icon: 'https://www.jqwidgets.com/angular/images/folder.png', label: 'Finance' },
{ icon: 'https://www.jqwidgets.com/angular/images/folder.png', label: 'Other' }
]
},
{ icon: 'https://www.jqwidgets.com/angular/images/recycle.png', label: 'Deleted Items' },
{ icon: 'https://www.jqwidgets.com/angular/images/notesIcon.png', label: 'Notes' },
{
iconsize: 14,
icon: 'https://www.jqwidgets.com/angular/images/settings.png',
label: 'Settings'
},
{ icon: 'https://www.jqwidgets.com/angular/images/favorites.png', label: 'Favorites' }
];
}
html, body {
width: 100vw;
height: 100vh;
padding: 0;
margin: 0;
}
jqxTree > div:first-child {
height: 100%;
border: none;
}
Options are inputs, bound with [name]="value".
Events are outputs named on plus the event name with a capital first letter. For example, select: This event is triggered when the user selects a tree item.
<jqxTree (onSelect)="onSelect($event)"></jqxTree>
onSelect(event: any): void {
console.log(event.args);
}
Get the component with a signal query and call its methods. For example, val: Sets or gets the selected item.
<jqxTree #myTree></jqxTree>
import { Component, viewChild } from '@angular/core';
import { jqxTreeModule, jqxTreeComponent } from 'jqwidgets-ng/jqxtree';
@Component({
selector: 'app-root',
imports: [jqxTreeModule],
templateUrl: './app.html'
})
export class App {
readonly myTree = viewChild.required<jqxTreeComponent>('myTree');
run(): void {
const value = this.myTree().val();
console.log(value);
}
}