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

Maintain Expanded State of TreeNode

1 Answer 84 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 24 Oct 2011, 05:27 PM
I'm working with the Telerik RadTreeView;

One objective for the functionality of the RadTreeView is to allow a User to either click the plus (+) sign (next to Node Name), or click the actual Node Name, and expand the Node;

<telerik:RadTreeView ID="RadTreeView1" runat="server"  
              
         OnNodeExpand="RadTreeView1_NodeExpand" ForeColor="Black" 
            Font-Names="Microsoft Sans Serif" 
            onnodeclick="RadTreeView1_NodeClick" Height="600px" Width="300px" 
                    Font-Size="Medium" OnClientNodeClicked="ClientNodeClicked">
                              
        </telerik:RadTreeView>

<script type="text/javascript" language="javascript">
    function ClientNodeClicked(sender, eventArgs) {
        var node = eventArgs.get_node();
        //alert("You clicked " + node.get_text());
        if (node) {
            node.expand();
        }
          
    }
</script>

The above code works briefly, and expands a selected RadTreeView Node for a split second; However, because the RadTreeView is being built dynamically in the C# code-behind, a post back occurs, and the expanded node quickly returns to an un-expanded state;

Thanks in advance for any insight;  Best regards - Rob

1 Answer, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 25 Oct 2011, 01:00 PM
Hello Robert ,

Here is a sample project that is showing a similar functionality as in the Load on Demand demo and works as expected on click.

All the best,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
TreeView
Asked by
Robert
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or