BoldDeskBoldDesk is now live on Product Hunt with a special offer: 50% off all plans. Let's grow together! Support us.
I am creating my dropdown tree list and have records in my data which is mapped to datasource
dropDownTreeObject = new ej.dropdowns.DropDownTree({
fields: { dataSource: data, value: 'Id', text: 'Name', child: 'ChildItems' },
});
dropDownTreeObject .appendTo('#ddtreeelement');
dropDownTreeObject .value = 1;
But when i am trying to set value
dropDownTreeObject.value = 1;
ddtree is not setting the value for 1 and my data list has a record with Id 1.
Do I need to map value in any other way for setting in dropdown tree list?
Hi Remya,
From the shared details, we understand that you want to bind value property for the Dropdown Tree component. You can follow the below way to achieve this requirement.
// Initialize the Dropdown Tree control 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, value: ['01'], }); treeObj.appendTo('#default'); |
Sample: https://stackblitz.com/edit/pdqzsg?file=index.html,index.ts
You can even bind multiple values just by specifying their corresponding values after enabling multi-selection in Dropdown Tree.
https://ej2.syncfusion.com/demos/#/bootstrap5/drop-down-tree/multiple-selection.html
Regards,
Indhumathy L
Thanks. It Worked....