RadTreeView1.GetXml not saving client side node state

3 posts, 1 answers
  1. Carl
    Carl avatar
    2 posts
    Member since:
    Mar 2012

    Posted 20 Mar 2012 Link to this post

    Hi all,

    I'm using RadTreeView1.GetXml to save the state of my TreeView and repopulate it after postbacks.

    I've done a test by replaceing text in a node, and based on that I can tell that saving and repopulating the TreeView is working fine.

    The problem is that when I contract some of the nodes, then select(Click on) a node, there is a posteback, and all the nodes are revertted to thier expanded state again.

    Expanding and contracting nodes seems to be happening on the client side,  as there is no postback when this happens.
    The postback dose happen when I click on a spesific node, that is when I use GetXml to save the state, but it dose not seem to be saving the updated state on the nodes.

    Here is the code, Please let me know what I am missing here.
    <telerik:RadTreeView ID="RadTreeView1" Runat="server"
        OnNodeClick="RadTreeView1_NodeClick" EnableDragAndDrop="True" Skin="Vista"
        OnNodeEdit="RadTreeView1_NodeEdit" OnNodeDrop="RadTreeView1_HandleDrop"
        SingleExpandPath="True" EnableViewState="true" >
                 <telerik:RadTreeViewContextMenu ID="RightClick" runat="server">
                    <telerik:RadMenuItem Value="NewParentNode" Text="Create New Parent Folder" >
                        <telerik:RadMenuItem Value="NewNode" Text="Create New Folder" >
                        <telerik:RadMenuItem IsSeparator="true">
                        <telerik:RadMenuItem Value="NewVirtualDocument" Text="New Virtual Document" >
                        <telerik:RadMenuItem Value="UploadPDF" Text="Upload PDF" >
                        <telerik:RadMenuItem IsSeparator="true">
                        <telerik:RadMenuItem Value="DeleteNode" Text="Delete Folder" >
                    <CollapseAnimation Type="none" />
    and server side
    protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs NodeEvent)
        clickedNode = NodeEvent.Node;
        ViewState["ClickedNode"] = clickedNode.Value.ToString();
        string savetreeViewState = RadTreeView1.GetXml();
        savetreeViewState = savetreeViewState.Replace("South Africa", "save state is working");
        Session["myTreeView"] = savetreeViewState;

    Thank you for your time.
  2. Answer
    Dimitar Terziev
    Dimitar Terziev avatar
    1266 posts

    Posted 23 Mar 2012 Link to this post


    In order to save the expended state of the RadTreeNodes you could use the approach from the following code library here.

    Dimitar Terziev
    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.
  3. Carl
    Carl avatar
    2 posts
    Member since:
    Mar 2012

    Posted 26 Mar 2012 Link to this post

    Thanks Dimitar, that fixed the problem.


    For anybody else who stumbles onto this thread with the same problem, the code library that Dimitar provided uses a cookie and JavaScript solution instead of the GetXml.

Back to Top