Hi,
Please see my example:
https://stackblitz.com/edit/vgf5xg-x6jjt5je?file=index.js
I am trying to expand/collapse the parent nodes on click
This works but it's a bit 'buggy': when I click the parent node 'Australia', the node expands but when I click 'Australia' again the node does not collapse unless I doubleclick the node. How can I achieve that the parent nodes expands/collapse on single click?
Secondly: how to select a 'child' value while selection of a parent value should be blocked ?(selection of parent node should only expand/collapse the node). So for example, how to select 'Acre' from the tree?
Thx
Frederik
var checkList = new ej.dropdowns.DropDownTree({ ... }); checkList.appendTo('#ddtree'); checkList.treeObj.nodeSelected = function (args) { ... }; //Define nodeChecked function checkList.treeObj.nodeClicked = function (args) { console.log(args); var nodeData = checkList.treeObj.getTreeData( args.node.getAttribute('data-uid') ); if (nodeData[0].hasChild) { if ( checkList.treeObj.expandedNodes.indexOf(nodeData[0].id.toString()) != -1 ) { checkList.treeObj.collapseAll(nodeData[0].id.toString()); } else { checkList.treeObj.expandAll(nodeData[0].id.toString()); } } else { checkList.value = [nodeData[0].id.toString()]; } }; |
Sivakumar S
Thanks a lot for your help!
Regards
Frederik
Maybe 1 addition:
After setting the value of the treeview you can hide popup with:
checkList.value = [nodeData[0].id.toString()];
checkList.hidePopup();
Frederik, thank you for your suggestion and for providing details on hiding the popup of Dropdown Tree component. This will certainly help other users to customize the component.