The Syncfusion® native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
When I use the DropDownTree control and bind it to an input, I'd expect the existing value of the input to initialize the selected single item in the tree drop down.
KRKeerthana Rajendran Syncfusion Team January 10, 2022 07:35 AM UTC
Hi Matt,
Thanks for contacting Syncfusion support.
You can get or set the value of EJ2 Dropdown Tree component using the value property. The change event will be triggered while changing the value in the Dropdown Tree.
Refer to the following code.
let treeObj: DropDownTree = new DropDownTree({
fields: {
dataSource: (dataSource as any).defaultData,
value: 'id',
text: 'name',
child: 'subChild',
expanded: 'expanded',
},
popupHeight: '200px',
placeholder: 'Select a folder or file',
changeOnBlur: false,
change: () => {
valueChange();
},
});
treeObj.appendTo('#default');
function valueChange(): void {
(document.getElementById('value') as any).value =
treeObj.value && treeObj.value.length > 0 ? treeObj.value[0] : ''; // get value
(document.getElementById('text') as any).value = treeObj.text;
}
document.getElementById('value').onchange = function () {