Using PrimeNG, I can scroll to a TreeNode:
In html:
<p-tree #mytreeid id="mytree"></p-tree>
In Angular:
@ViewChild("mytree") mytree: Tree;
// selection is the TreeNode you want to scroll into view
scrollToSelectionPrimeNgDataTree(selection, tree, elementIdName) {
if (tree.value !== null) {
let index = tree.value.indexOf(selection);
let ele = document.getElementById(elementIdName).querySelectorAll("p-treenode")[index];
ele.scrollIntoView();
//ele.focus();
}
}
Question: How to make the TreeNode(ie. 'selection') focused? I tried to call the focus() method, but focus() is not the method of the Element.