Node text returns null until clicked

3 posts, 0 answers
  1. Joe Burton
    Joe Burton avatar
    2 posts
    Member since:
    Oct 2008

    Posted 21 Oct 2009 Link to this post

    I'm using the selected nodes in a treeview to populate a simple breadcrumb in my tab strip on the client side.  If I haven't clicked on the parent node first then it will return null.  Here is the code that is driving the functionality.  Any help would be greatly appreciated...

            function OnClientNodeClicked(sender, args)
            {
                var treeView = $find("<%= RadTreeView1.ClientID %>");
                var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
                var selectedTab = tabStrip.get_selectedTab();
                var selectedNode = treeView.get_selectedNode();
                var parentNode = selectedNode.get_parent();
                if (selectedNode.get_level() == 0)
                {
                    selectedTab.set_text(selectedNode._text);
                } else {
                    selectedTab.set_text(parentNode._text + " -> " + selectedNode._text);
                }
            }

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 22 Oct 2009 Link to this post

    Hi Joe,

    Give a try with following client side code in order to show the breadcrumb for RadTreeView.

    JavaScript:
     
     function onMouseOver(sender, args) 
     {  
           var node = args.get_node(); 
           var s = node.get_text(); 
           var currentObject = node.get_parent();        
           while (currentObject != null
           { 
             // get_parent() will return null when we reach the treeview 
             if (currentObject.get_parent() != null
             { 
               s = currentObject.get_text() + " > " + s; 
             } 
             currentObject = currentObject.get_parent(); 
           } 
            // Here s contains th path 
            // Your code to for setting the tabstrip text 
       }  

    Thanks,
    Princy.
  3. Joe Burton
    Joe Burton avatar
    2 posts
    Member since:
    Oct 2008

    Posted 22 Oct 2009 Link to this post

    That did the trick...I put the code in my OnClientNodeClicked event.  Posting the final version that works like a charm.  Thanks...

           function OnClientNodeClicked(sender, args)  
           {    
            var node = args.get_node();   
            var s = node.get_text();   
            var currentObject = node.get_parent();          
            while (currentObject != null)   
            {   
                // get_parent() will return null when we reach the treeview   
                if (currentObject.get_parent() != null)   
                {   
                s = currentObject.get_text() + " > " + s;   
                }   
                currentObject = currentObject.get_parent();  
            }   
            var tabStrip = $find("<%= RadTabStrip1.ClientID %>");  
            var selectedTab = tabStrip.get_selectedTab();  
            selectedTab.set_text(s)  
           } 
Back to Top