Following code does not scroll to tree node - used elsewhere in same file it works fine (ie when creating a new node).
tree.loadXMLString(xmlStr);
if (id!=“”) {
tree.selectItem(id,true);
tree.focusItem(id,true);
Tree node is selected and scrolling takes place but not to selected treenode.
Tried waiting till tree loaded ie loadXMLString(xmlStr, myFunc(id,tree));
and then doing the select/focus in myFunc() but that did not work - even
kept existing code lines above ie double select/focus. Also tried to use
an alert() in myFunc() to delay the select/focus and still no good.
So I’ve removed the focus so at least tree does not scroll and ‘hide’ the
selected node
There is no any known limitation which can cause problem for the above code.
Beware that focusItem call will only scroll content inside the tree, it will not affect any other scrollable areas on the page.
As possible workaround you can try to organize your code as
Thanks for looking into this but it does not work.
But I have a something that works but I dont know why.
Firstly not sure what you mean by
“Beware that focusItem call will only scroll content inside the tree”
The tree is in the top panel of Layout pattern 3E
Below is what works, fails and a soln.
Take tree below with 4 levels
4th level has nodes 0,1,2,3,…,17
Eg tree
1
\2
\3
\4
|0
:
|17*
[a] what works
If 4 is selected and I create a new sub node eg 17*
then the code select/focus will scroll and select 17
ie 17 is highlighted and appears in the layout panel
[b] what does not work
select 17 and scroll panel till 17 is at bottom of panel
‘do a refresh’ ie delete and recreate tree using
loadXMLString then the code does a select/focus 17 but instead
of the tree scrolling so that 17 is highlighted in the panel
eg 12 is highlighted and 17 is not visible but if I scroll down
to 17 it is highlighted ie selected
[c] solution
tree.loadXMLString(xmlStr);
if (id!="") {
tree.selectItem(id,true);
tree.focusItem(0,true); <<<<<<<<< new line
tree.focusItem(id,true);
Now refreshed tree always selects/highlights 17 and is visible
in the panel