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

RadTreeView1.GetXml not saving client side node state

2 Answers 37 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Carl
Top achievements
Rank 1
Carl asked on 20 Mar 2012, 02:12 PM
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"
    OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick"
    OnNodeEdit="RadTreeView1_NodeEdit" OnNodeDrop="RadTreeView1_HandleDrop"
    SingleExpandPath="True" EnableViewState="true" >
    <ContextMenus>
             <telerik:RadTreeViewContextMenu ID="RightClick" runat="server">
                <Items>
                <telerik:RadMenuItem Value="NewParentNode" Text="Create New Parent Folder" >
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="NewNode" Text="Create New Folder" >
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem IsSeparator="true">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="NewVirtualDocument" Text="New Virtual Document" >
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="UploadPDF" Text="Upload PDF" >
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem IsSeparator="true">
                    </telerik:RadMenuItem>
                    <telerik:RadMenuItem Value="DeleteNode" Text="Delete Folder" >
                    </telerik:RadMenuItem>
                </Items>
                <CollapseAnimation Type="none" />
            </telerik:RadTreeViewContextMenu>
      </ContextMenus>
</telerik:RadTreeView>
and server side
protected void RadTreeView1_NodeClick(object sender, RadTreeNodeEventArgs NodeEvent)
{
    clickedNode = NodeEvent.Node;
    ViewState["ClickedNode"] = clickedNode.Value.ToString();
    createDynamicTable(Convert.ToInt32(ViewState["ClickedNode"].ToString()));
 
    string savetreeViewState = RadTreeView1.GetXml();
    savetreeViewState = savetreeViewState.Replace("South Africa", "save state is working");
    Session["myTreeView"] = savetreeViewState;
 }

Thank you for your time.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar Terziev
Telerik team
answered on 23 Mar 2012, 02:30 PM
Hi,

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

Greetings,
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.
0
Carl
Top achievements
Rank 1
answered on 26 Mar 2012, 09:52 AM
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.


Regards
Tags
TreeView
Asked by
Carl
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Carl
Top achievements
Rank 1
Share this question
or