Implement Syncfusion Dropdown Tree control to display hierarchical data in dropdown format. Use this skill when implementing single or multiple value selection from hierarchical data, enabling checkboxes with dependent parent-child states, lazy-loading large datasets, customizing tree items with templates, and configuring multi-language support. Comprehensive coverage of properties, methods, events, data binding modes, checkbox selection, templates, and accessibility features.
Use the Dropdown Tree control when you need to:
The Dropdown Tree is ideal for scenarios like organizational hierarchies, category selections, location/region pickers, and permission/role management interfaces.
The Syncfusion Dropdown Tree control allows you to select single or multiple values from hierarchical data displayed in a tree structure. Key features include:
📄 Read: references/getting-started.md
📄 Read: references/data-binding.md
📄 Read: references/checkbox-features.md
import { DropDownTree } from '@syncfusion/ej2-dropdowns';
// Define hierarchical data
let continents = [
{
code: 'AF',
name: 'Africa',
countries: [
{ code: 'NGA', name: 'Nigeria' },
{ code: 'EGY', name: 'Egypt' }
]
},
{
code: 'AS',
name: 'Asia',
expanded: true,
countries: [
{ code: 'IND', name: 'India', selected: true },
{ code: 'JPN', name: 'Japan' }
]
}
];
// Initialize Dropdown Tree
let ddtree = new DropDownTree({
fields: {
dataSource: continents,
value: 'code',
text: 'name',
child: 'countries'
}
});
ddtree.appendTo('#ddtElement');
<input type="text" id="ddtElement" />
Hierarchical data uses nested arrays to represent parent-child relationships:
let hierarchicalData = [
{
id: 1,
name: 'Parent Item',
children: [
{ id: 2, name: 'Child 1' },
{ id: 3, name: 'Child 2' }
]
}
];
Self-referential data uses parent ID references:
let selfRefData = [
{ id: 1, name: 'Parent', parentId: null },
{ id: 2, name: 'Child 1', parentId: 1 },
{ id: 3, name: 'Child 2', parentId: 1 }
];
allowMultiSelection: true or showCheckBox: trueWhen autoCheck: true in treeSettings:
The fields property uses FieldsModel to map data source fields to Dropdown Tree properties.
| Property | Type | Description | Example |
|---|---|---|---|
dataSource | DataManager | Object[] | Array of data or DataManager instance | [{...}, {...}] |
value | string | Field name for item value/ID | 'id' or 'code' |
text | string | Field name for display text | 'name' or 'title' |
child | string | FieldsModel | Field name for child collection (hierarchical) | 'children' or 'items' |
parentValue | string | Field name for parent reference (self-referential) | 'parentId' or 'pid' |
hasChildren | string | Field name indicating if item has children | 'hasChild' or 'hasItems' |
expanded | string | Field name for expanded state | 'expanded' or 'isExpanded' |
selected | string | Field name for selected state | 'selected' or 'isSelected' |
iconCss | string | Field name for icon CSS class | 'iconClass' |
imageUrl | string | Field name for image URL | 'imageUrl' or 'icon' |
htmlAttributes | string | Field name for HTML attributes | 'htmlAttrs' |
tooltip | string | Field name for tooltip text | 'title' or 'tooltip' |
selectable | string | Field name for item selectability | 'canSelect' |
query | Query | External query for DataManager | Custom Query object |
tableName | string | Table name for server-side data | 'EmployeeTable' |
let ddtree = new DropDownTree({
fields: {
dataSource: hierarchicalData,
value: 'id',
text: 'name',
child: 'subitems',
expanded: 'isExpanded',
iconCss: 'iconClass'
}
});
ddtree.appendTo('#ddtElement');
let ddtree = new DropDownTree({
fields: {
dataSource: selfRefData,
value: 'id',
text: 'name',
parentValue: 'parentId',
hasChildren: 'hasChild'
}
});
ddtree.appendTo('#ddtElement');
import { DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let ddtree = new DropDownTree({
fields: {
dataSource: new DataManager({
url: 'https://services.odata.org/V4/Northwind/Northwind.svc/Employees',
adaptor: new ODataV4Adaptor()
}),
value: 'EmployeeID',
text: 'FirstName',
hasChildren: 'EmployeeID'
}
});
ddtree.appendTo('#ddtElement');
The treeSettings property uses TreeSettingsModel to configure tree-specific behavior.
| Property | Type | Description | Default |
|---|---|---|---|
loadOnDemand | boolean | Enable lazy loading of child items | false |
autoCheck | boolean | Enable parent-child checkbox dependency | false |
checkDisabledChildren | boolean | Include disabled children in parent check | false |
expandOn | ExpandOn | Trigger for expand/collapse action | ExpandOn.Auto |
| Value | Description |
|---|---|
Auto | Double-click on desktop, single-tap on mobile |
Click | Single-click/tap on both desktop and mobile |
DblClick | Double-click/tap on both desktop and mobile |
None | Expand/collapse disabled |
let ddtree = new DropDownTree({
fields: { dataSource: data, value: 'id', text: 'name', parentValue: 'pid' },
treeSettings: {
loadOnDemand: true // Children load when parent expands
}
});
ddtree.appendTo('#ddtElement');
let ddtree = new DropDownTree({
fields: { dataSource: data, value: 'id', text: 'name', parentValue: 'pid' },
showCheckBox: true,
treeSettings: {
autoCheck: true,
checkDisabledChildren: true // Disabled items get checked too
}
});
ddtree.appendTo('#ddtElement');
let ddtree = new DropDownTree({
fields: { dataSource: data, value: 'id', text: 'name', parentValue: 'pid' },
treeSettings: {
expandOn: 'Click' // Single-click to expand/collapse
}
});
ddtree.appendTo('#ddtElement');
📄 Complete API properties documentation with examples and type specifications
What's Inside:
📄 Complete API methods documentation with parameter details and examples
What's Inside:
📄 Complete API events documentation with event argument properties and examples
What's Inside:
let ddtree = new DropDownTree({
fields: { dataSource: data, value: 'id', text: 'name', parentValue: 'pid' },
showCheckBox: true,
showSelectAll: true,
treeSettings: { autoCheck: true },
change: (args) => {
console.log('Selected items:', args.value);
}
});
ddtree.appendTo('#ddtElement');
Use when: User needs to select multiple items with parent-child dependency.
let ddtree = new DropDownTree({
fields: {
dataSource: dataManager,
value: 'id',
text: 'name',
parentValue: 'parentId'
},
treeSettings: { loadOnDemand: true }
});
ddtree.appendTo('#ddtElement');
Use when: Working with large hierarchies (1000+ items).
let ddtree = new DropDownTree({
fields: { dataSource: data, text: 'name', value: 'id' },
itemTemplate: '<div class="item-row"><span>${name}</span> <small>${department}</small></div>',
valueTemplate: '<span class="selected-badge">${name}</span>'
});
ddtree.appendTo('#ddtElement');
Use when: Need to display additional data fields.
import { DataManager, ODataV4Adaptor } from '@syncfusion/ej2-data';
let ddtree = new DropDownTree({
fields: {
dataSource: new DataManager({
url: 'https://api.example.com/items',
adaptor: new ODataV4Adaptor()
}),
value: 'id',
text: 'name'
},
allowFiltering: true,
filterBarPlaceholder: 'Search items...',
filterType: 'Contains'
});
ddtree.appendTo('#ddtElement');
Use when: Fetching data from remote service with search capability.
let ddtree = new DropDownTree({
fields: { dataSource: data, value: 'id', text: 'name', parentValue: 'pid' },
showCheckBox: true,
showSelectAll: true,
selectAllText: 'Select All Items',
unSelectAllText: 'Clear All',
mode: 'Delimiter',
delimiterChar: '; ',
allowMultiSelection: true
});
ddtree.appendTo('#ddtElement');
Use when: Want friendly checkbox text and delimited display.
let ddtree = new DropDownTree({
fields: { dataSource: [], value: 'id', text: 'name', child: 'items' }
});
ddtree.appendTo('#ddtElement');
// Later, update data
let newData = [{ id: 1, name: 'Item 1', items: [] }];
ddtree.fields.dataSource = newData;
ddtree.refresh(); // Re-render
Use when: Data changes dynamically after initialization.
let ddtree = new DropDownTree({
fields: { dataSource: data, value: 'id', text: 'name', child: 'items' },
showCheckBox: true,
change: (args) => {
if (args.value.length > 5) {
console.warn('Maximum 5 items can be selected');
// Reset to previous value
ddtree.value = args.oldValue;
}
}
});
ddtree.appendTo('#ddtElement');
Use when: Need to enforce selection constraints.
Scenario: Department/Employee selection with multi-select and role assignment
let employees = [
{ id: 1, name: 'IT Department', hasChild: true },
{ id: 2, pid: 1, name: 'John Doe', department: 'IT' },
{ id: 3, pid: 1, name: 'Jane Smith', department: 'IT' },
{ id: 4, name: 'HR Department', hasChild: true },
{ id: 5, pid: 4, name: 'Mike Johnson', department: 'HR' }
];
let ddtree = new DropDownTree({
fields: {
dataSource: employees,
value: 'id',
text: 'name',
parentValue: 'pid',
hasChildren: 'hasChild'
},
showCheckBox: true,
treeSettings: { autoCheck: true },
itemTemplate: '<div>${name} <span class="text-muted">${department}</span></div>',
change: (args) => {
assignRolesToSelectedEmployees(args.value);
}
});
ddtree.appendTo('#employeeSelection');
Scenario: Country → State → City selection with lazy loading
import { DataManager, WebApiAdaptor } from '@syncfusion/ej2-data';
let ddtree = new DropDownTree({
fields: {
dataSource: new DataManager({
url: 'api/locations',
adaptor: new WebApiAdaptor()
}),
value: 'id',
text: 'name',
parentValue: 'parentId',
hasChildren: 'hasChildren'
},
treeSettings: {
loadOnDemand: true // Load children on demand
},
allowFiltering: true,
filterBarPlaceholder: 'Search locations...',
change: (args) => {
updateMapWithSelectedLocation(args.value);
}
});
ddtree.appendTo('#locationPicker');
Scenario: Display product categories with item counts and icons
let categories = [
{
id: 'cat1',
name: 'Electronics',
count: 125,
icon: 'e-icons e-mobile',
products: [
{ id: 'prod1', name: 'Mobile Phones', count: 45, icon: 'e-icons e-phone' },
{ id: 'prod2', name: 'Laptops', count: 30, icon: 'e-icons e-laptop' }
]
}
];
let ddtree = new DropDownTree({
fields: {
dataSource: categories,
value: 'id',
text: 'name',
child: 'products',
iconCss: 'icon'
},
itemTemplate: `
<div class="category-item">
<i class="\${icon}"></i>
<span>\${name}</span>
<span class="badge">\${count}</span>
</div>
`,
change: (args) => {
filterProductsByCategories(args.value);
}
});
ddtree.appendTo('#categorySelector');
Scenario: Multi-level permission hierarchy with selective enabling
let permissions = [
{ id: 'admin', name: 'Admin', hasChild: true },
{ id: 'admin-users', pid: 'admin', name: 'Manage Users' },
{ id: 'admin-system', pid: 'admin', name: 'System Settings' },
{ id: 'user', name: 'User', hasChild: true, disabled: true },
{ id: 'user-profile', pid: 'user', name: 'Edit Profile' }
];
let ddtree = new DropDownTree({
fields: {
dataSource: permissions,
value: 'id',
text: 'name',
parentValue: 'pid',
hasChildren: 'hasChild'
},
showCheckBox: true,
showSelectAll: true,
selectAllText: 'Grant All Permissions',
unSelectAllText: 'Revoke All Permissions',
treeSettings: { autoCheck: true },
change: (args) => {
savePermissionsToRole(args.value);
}
});
ddtree.appendTo('#permissionSelector');
For implementation assistance with specific features or advanced scenarios, reference the appropriate guide above.