Home - Forums-.NET - FlyTreeView (ASP.NET) - expanding nodes on the client problem

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

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

expanding nodes on the client problem
Link Posted: 11-May-2008 02:30
I have a ptentially large treeview.  I'd like to be able to load the thing after page load; thereby not delaying the page until the flytreeview loads.  i am having as issue.  my code expands the root node and then I've tried several different methods to expand the children to no avail.  I am on this (see below) if I stick an alert at certain points in the code it will load the whole darn thing, otherwise it keeps silently failing.  it appears that even though the node is expanded and populated getchildnodes comes back as nothing.






var treeview;
var exto;
var lastnode;
function flyTreeView_onInitialized(treeviewObject) {
    treeview = treeviewObject;
    
    exto = document.getElementById('').value;

    if (exto > 0) {
    //get the nodes
    var nodes  = treeview.getNodes();
  
   //loop through the root nodes
    for (i=0;i    
    nodes[i].expand();
    
   }//loop the root
    
     }
    }

    function onNodeEventHandler(sender, node, eventType) {
    if (eventType == 'expanded') {
    var lev = node.getLevel();
    if (lev < exto) {
    lastnode = node;
    }// if lev < exto
    }//if expanded
    else if (eventType == 'populated'){
    if (lev < exto) {
    var nodes = lastnode.getChildNodes();
       for (i=0;i<=nodes.length;i++){
       nodes[i].expand();
    
    }//loop
    }// if lev < exto
    }//else if
    }//onNodeEventHandler
    
                    




    OnInitializedJavascript="flyTreeView_onInitialized"  OnNodeEventJavascript="onNodeEventHandler" FadeEffect="True"
    SlideEffect="True">







    
                                            ContentClickCollapses="False" ContentClickTogglesCheckbox="False"
                        CanBeSelected="True" IsCheckbox="False" AutoApplyAtLevels="0">
                        
                        
                        
                        
                        
                        
                        
                        
                    
                                            PostBackOnSelect="False" PostBackOnDeselect="False" PostBackOnCollapse="False"
                        ContentClickCollapses="False" CanBeSelected="False" IsCheckbox="False">
                        
                        
                        
                        
                        
                        
                        
                        
                    
                                            PostBackOnUncheck="True">
                        
                        
                        
                        
                        
                        
                        
                        
                    
                    
                        
                        
                        
                        
                        
                        
                        
                        
                    
                                            PostBackOnUncheck="True">
                        
                        
                        
                        
                        
                        
                        
                        
                    
                


        
Link Posted: 11-May-2008 02:49
Why don't you use simple ExpandLevel property to expand required levels of nodes automatically?
Link Posted: 11-May-2008 03:40
that delays the page load until the thing fills out.  The point it to allow the page to load and then fill in the tree view.
Link Posted: 11-May-2008 09:10
unless I am missing something this is an issue, client retreived nodes do not exist until there is some sort of user interaction.  i found a partial work around ...

I simply load the first set of nodes from the client and then in the onpopulatenodes event (? I am not looking at the code, I hop ethi si the righ tname) on the server I push the expandlevel to 4.  This allows the page to load and the flytreeview then shows the root node with loading.. under it.

I rather see the nodes load in the cascade effect i was originally hoping for but i know that might be asking a lot.

if i am missing something or if there is a better alternative; i hope somewill let me know.

TTFN
Link Posted: 12-May-2008 03:06
Yes, there's an issue.
Now trying to figure out possible solutions.
Link Posted: 20-Jun-2008 13:45
anything?
Link Posted: 20-Jun-2008 21:17
Yes, not a fix, but rather a workaround - see the code bellow: [code] <%@ Register Assembly="NineRays.WebControls.FlyTreeView" Namespace="NineRays.WebControls" TagPrefix="NineRays" %> Untitled Page
var treeview; var exto; var lastnode; function flyTreeView_onInitialized(treeviewObject) { treeview = treeviewObject; exto = document.getElementById('').value; window.setTimeout(function() {delayedExpandNodeOrTreeView(null, treeviewObject);}, 200); } function onNodeEventHandler(sender, node, eventType) { if (eventType == 'populated') { window.setTimeout(function() {delayedExpandNodeOrTreeView(node, null);}, 200); } } function delayedExpandNodeOrTreeView(node, treeview) { var nodes; if (node && node.getLevel() < exto) { nodes = node.getChildNodes(); } else if (treeview && exto > 0) { nodes = treeview.getNodes(); } for (var i = 0; nodes && (i < nodes.length); i++) { nodes[i].expand(); } }
[/code] Anyways, I do not completely get the idea. From my point of view, you cat set ExpandLevel or expand certain levels of nodes at server-side. So all required nodes will be rendered with the page and do not require additional callbacks, etc.