<ejs-dropdownlist id="dropdown " open="open" noRecordsTemplate="<div id='tree'></div>">
</ejs-dropdownlist>
<script>
function open() {
var treeObj;
var dropdownObj = document.getElementById("dropdown").ej2_instances[0];
dropdownObj.popupObj.element.firstElementChild.className = "e-content overflow";
// rendering the treeview only on first time
if (treeObj == null || treeObj == undefined) {
treeObj = new ej.navigations.TreeView({
fields: { dataSource: localData, id: 'id', parentID: 'pid', text: 'name', hasChildren: 'hasChild' },
// use the nodeselected event to add the text to dropdown's input element.
nodeSelected: function(args){
var drop = document.getElementById("dropdown").ej2_instances[0];
drop.inputElement.value = args.nodeData.text;
}
});
treeObj.appendTo('#tree');
}
}
</script> |