Loading...
Loading...
Implement Syncfusion Angular Dropdown Tree component for hierarchical data selection with single or multiple values. Use this when selecting items from tree-structured hierarchies, enabling checkboxes for multi-selection, binding hierarchical data, customizing tree items with templates, or implementing parent-child dependent selection. Works with self-referential structures and remote OData/REST endpoints for category selectors and organizational interfaces.
npx skill4agent add syncfusion/angular-ui-components-skills syncfusion-angular-dropdowntreeimport { Component } from '@angular/core';
import { DropDownTreeModule } from '@syncfusion/ej2-angular-dropdowns';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'app-dropdown-tree',
template: `<ejs-dropdowntree id='dropdowntree'
[fields]='fields'
placeholder='Select a category'></ejs-dropdowntree>`,
standalone: true,
imports: [DropDownTreeModule, FormsModule, ReactiveFormsModule]
})
export class AppComponent {
// Hierarchical data structure with nested arrays
public data = [
{
nodeId: '01', nodeText: 'Music',
nodeChild: [
{ nodeId: '01-01', nodeText: 'Gouttes.mp3' }
]
},
{
nodeId: '02', nodeText: 'Videos', expanded: true,
nodeChild: [
{ nodeId: '02-01', nodeText: 'Naturals.mp4' },
{ nodeId: '02-02', nodeText: 'Wild.mpeg' }
]
}
];
// Field mapping: value=nodeId, text=nodeText, child=nodeChild
public fields = {
dataSource: this.data,
value: 'nodeId',
text: 'nodeText',
child: 'nodeChild'
};
}@Component({
template: `<ejs-dropdowntree id='dropdowntree'
[fields]='fields'
[showCheckBox]='true'
[showSelectAll]='true'
selectAllText='Check All'
unSelectAllText='Uncheck All'></ejs-dropdowntree>`,
standalone: true,
imports: [DropDownTreeModule, FormsModule, ReactiveFormsModule]
})
export class CheckboxExample {
public data = [
{ id: 1, name: 'Music', hasChild: true, expanded: true },
{ id: 2, pid: 1, name: 'Hot Singles' },
{ id: 3, pid: 1, name: 'Rising Artists' }
];
public fields = {
dataSource: this.data,
value: 'id',
text: 'name',
parentValue: 'pid',
hasChildren: 'hasChild'
};
}selectAllTextunSelectAllText@Component({
template: `<ejs-dropdowntree [fields]='fields'
[showCheckBox]='true'
[treeSettings]='{ autoCheck: true }'></ejs-dropdowntree>`
})
export class AutoCheckExample {
public fields = { dataSource: this.data, /* ... */ };
}import { DataManager, ODataV4Adaptor, Query } from '@syncfusion/ej2-data';
@Component({
template: `<ejs-dropdowntree [fields]='fields'></ejs-dropdowntree>`
})
export class RemoteDataExample {
public data = new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc',
adaptor: new ODataV4Adaptor,
crossDomain: true
});
public fields = {
dataSource: this.data,
query: new Query().from('Employees').select('EmployeeID,FirstName').take(5),
value: 'EmployeeID',
text: 'FirstName',
hasChildren: 'EmployeeID'
};
}@Component({
template: `<ejs-dropdowntree [fields]='fields'
[itemTemplate]='itemTemplate'></ejs-dropdowntree>`
})
export class TemplateExample {
public itemTemplate = '<div><strong>${name}</strong> - ${type}</div>';
public fields = { dataSource: this.data, /* ... */ };
}| Feature | Use Case |
|---|---|
| Hierarchical Data | Organize items in parent-child relationships (categories, departments, file trees) |
| Checkboxes | Enable multi-selection without affecting dropdown UI |
| Auto-Check | Synchronize parent-child selection states automatically |
| Remote Binding | Fetch data from OData, REST APIs, or custom endpoints |
| Templates | Customize item display, headers, footers, and selected value format |
| Accessibility | Full keyboard navigation, ARIA attributes, screen reader support |
| Localization | Support for multiple languages and regional formats |
| Select All | Quickly select or deselect all items with a single click |