Home - Forums-.NET - FlyTreeView (ASP.NET) - Scrolling to selected node.

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Scrolling to selected node.
Link Posted: 13-Mar-2007 11:59
Hello,

Is there a way to scroll to a selected node with code if the node is below the bottom of the control?
Link Posted: 13-Mar-2007 14:14
Yes, you just need to set
FlyTreeView.FocusNode to node you need to scroll to.
like:
flytreeview.FocusNode = flytreeview.SelectedNode;

Also you should have this node visible (all parent nodes expanded).
Link Posted: 20-Aug-2007 03:13
[quote="EvgenyT"]Yes, you just need to set
FlyTreeView.FocusNode to node you need to scroll to.
like:
flytreeview.FocusNode = flytreeview.SelectedNode;

Also you should have this node visible (all parent nodes expanded).


Hi there, I'm borrowing this thread for a similiar problem. It seems I can't focus my node at all. I get a javascript error:

"Can't move focus to the control because it is invisible, not enabled, or of type that does not accept the focus.".

The thing is, I populate my tree on demand, and when I navigate to the new page, I expand the tree with my path according to the following thread:

http://www.9rays.net/forums/viewtopic.php?t=1736

And it works fine. The last node is selected. But I want my scrollbar to follow along. So after the above code, which btw is in my page_load of the masterpage, I do:

MyTree.FocusNode = MyTree.SelectedNode;

But I get the javascript error. What am I doing wrong?

BR
Link Posted: 20-Aug-2007 03:23
[quote="EvgenyT"]

Also you should have this node visible (all parent nodes expanded).


And also, I have all my parents expanded, all the way up to the root.

x1
|-- x2
|---- x3
|------ x4 <- the selectednode
Link Posted: 20-Aug-2007 06:54
Recently, there was a fix regarding similar issue.
Please try to use the latest version from our site:

http://www.9rays.net/download.aspx?productFamily=TreeView_ASP.NET_2
Link Posted: 20-Aug-2007 19:21
Hi Evgeny,

I downloaded the latest version from your site today and tried. Still the same error. What I am doing is the following:


FlyTreeNodeCollection nodes = MyTree.Nodes;
FlyTreeNodeCollection sn;

string[] values = PATH.Split('-');
string lastNode = values[values.Length - 1];

foreach (string s in values)
{
      sn = nodes.FindByValue(s, true);

       foreach (FlyTreeNode ftn in sn)
       {
           ftn.Expanded = true;
           MyTree.PopulateExpandedNodes();
           nodes = ftn.ChildNodes;

           if (String.Equals(s, lastNode))
           {
                  ftn.Selected = true;
           }
        }
}

MyTree.FocusNode = MyTree.SelectedNode;


This in my page_load method of my masterpage. On every navigateUrl, this code successfully expands my tree according to the PATH-variable, and selects the last node. However:


MyTree.FocusNode = MyTree.SelectedNode;


fails and throws a javascript error when the page is loaded, the tree expanded and my node selected. Everything else works fine.  

Could you see any errors in my code or am I doing something else wrong? The funny thing is, that MyTree.SelectedNode is not null, it is actually a node. Yet still it cannot be \"focused\" according to the javascript error.

My tree is like this:


                                            ID=\"MyTree\"
                        runat=\"server\"
                        ImageSet=\"MSDN\"
                        BarBackgroundImage=\"$bar_green\"
                        ContentClickCollapses=\"true\"
                        ContentClickExpands=\"true\"
                        DisplayBar=\"true\"
                        DrawLines=\"true\"
                        FadeEffect=\"true\"
                        ChildIndent=\"20\"
                        BarWidth=\"25\"
                        Padding=\"5px\"
                        BorderStyle=\"None\"
                        PathSeparator=\"-\"
                        CanBeSelected=\"true\"
                        OnPopulateNodes=\"MyTree_OnPopulateNodes\">

                    


Thanks in advance!

BR
Link Posted: 20-Aug-2007 19:36
By the way, we found the problem, however we still need a solution. The problem is that our tree is inside another control. If we move the tree outside the control, the code works.

Should I somehow reference my tree in some other way when I call the FocusNode method?
Link Posted: 20-Aug-2007 21:16
Actually the error you get means that the nodeElement.focus() function is called when the nodeElement is not visible. Is it possible in your case?

What is the owner control?
How can we emulate your environment? Can you send any code that can help us to reproduce the error.
Link Posted: 20-Aug-2007 21:26
[quote="EvgenyT"]Actually the error you get means that the nodeElement.focus() function is called when the nodeElement is not visible. Is it possible in your case?

What is the owner control?
How can we emulate your environment? Can you send any code that can help us to reproduce the error.


Hi,

the control we are using is obout splitter control:


It's fairly simple to reproduce. The code is like this. We have it in our masterpage:



      
        
                         // The flytreeview goes here...
        
    
      
        
                    
                         // content goes here...
                    
        
      
    


As you see, the tree is in the left panel, and content in the right panel. In my masterpage I use the code I posted before to expand all nodes and focus the last selected one. This works when flytreeview is outside this control.

Everything works fine, except for the focus thing.

Also, when I move it outside the splitter-control, it works just fine. Even if I put it into a standard asp.net control.  

Could you see if there is any way around this? Is the error in the splitter or in the flytreeview? I understand if you don't support this matter, however it would be nice if you could look at it.

Thankx!
[/code][code][/code]
Link Posted: 20-Aug-2007 21:52
Actually, the problem is that Splitter renders DIV elements with display:none.
So that is the reason why FlyTreeView generates the error.

Now, I'm thinking what we can do to workaround the issue.