This is a migrated thread and some comments may be shown as answers.

WCF load on demand but expand first level

2 Answers 29 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
BitShift
Top achievements
Rank 1
Veteran
BitShift asked on 09 Sep 2014, 02:19 PM
Im looking for a suggestion on how to cause the first node to show expanded.  Im using a WCF service with load-on-demand and that works fine.  Its just that the tree is completely collapsed and id like to cause the 1st level to be shown.  

Ive thought about something like this.  Just look for the root node and cause expand it.
The question then is ...where to do this from?  On page load?  
http://www.telerik.com/help/aspnet-ajax/treeview-client-expand-parent-nodes.html

2 Answers, 1 is accepted

Sort by
0
BitShift
Top achievements
Rank 1
Veteran
answered on 09 Sep 2014, 02:20 PM
Oh, and I forgot to mention that the tree is inside an ajax panel
0
BitShift
Top achievements
Rank 1
Veteran
answered on 09 Sep 2014, 03:11 PM
Found a solution.  Just add a javascript handler on the tree itself for 'OnClientLoad'
Something like this
            function pageTreeLoad(sender, eventArgs) {
                var tree = $find("<%= MyTree.ClientID %>");
                var node = tree.findNodeByText("Root Node Text Here...");
                if (node != null) {
                    node.expand();
                }

this causes the WCF load on demand to fire and load the 1st level node list
            }
Tags
TreeView
Asked by
BitShift
Top achievements
Rank 1
Veteran
Answers by
BitShift
Top achievements
Rank 1
Veteran
Share this question
or