Set Focus on tree view on load of the page

I have two tree views treeView1, treeView2 in a page getting displayed in separate divs.



I want to focus on treeView1 on load of the page.



I have used - treeView1.focusItem(itemId); to focus atleast rootnode of treeView1.



But it does not work.



Please help me in resolving this.





Thanks alot.



In which moment you are executing such command?
Please beware that tree loading is async, so you need to catch moment of data loading

    tree.loadXML(url, function(){
        treeView1.focusItem(itemId);
    })


Also please be sure that tree container has not “overflow:auto” style, because in such case external scrollbars will be rendered, while tree can adjust only inner scrollbars to show item in question.