Roatin Marth
Top achievements
Rank 1
Roatin Marth
asked on 03 Sep 2009, 04:08 AM
The RadTreeNode js class has the function toJsonString, but what good is it without a function to deserialize it back into a RadTreeNode object.
I tried using _loadFromDictionary but it didn't seem to work and it is a private method.
Am I missing something?
Thanks
I tried using _loadFromDictionary but it didn't seem to work and it is a private method.
Am I missing something?
Thanks
3 Answers, 1 is accepted
0
Hi Roatin Marth,
The usage of the toJsonString method is shown in this example. There the string is used on the server-side. Currently the _loadFromDictionary method accepts a JSON object rather than string so it cannot be used. Could you please let us know your requirements?
Sincerely yours,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The usage of the toJsonString method is shown in this example. There the string is used on the server-side. Currently the _loadFromDictionary method accepts a JSON object rather than string so it cannot be used. Could you please let us know your requirements?
Sincerely yours,
Atanas Korchev
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Roatin Marth
Top achievements
Rank 1
answered on 03 Sep 2009, 01:43 PM
I need to be able to serialize and deserialize a node on the client side. I have a node with several attributes, text, image etc. that I need the app to be able to remember. Whats happening is I'm working on a page that still uses post backs in some cases which causes the client side state to be wiped out. So I'm serializing this special node (It's not a selected node, just a special node I want to remember) and sticking it in a hidden field so after a postback I have the ability to bring it back into the client side.
However at this point there is no equivalent function to deserialize in the client side. So thats what I'm missing.
By the way I tried calling Sys.Serialization.JavaScriptSerializer.deserialize() before _loadFromDictionary and it still didn't work.
Thanks
However at this point there is no equivalent function to deserialize in the client side. So thats what I'm missing.
By the way I tried calling Sys.Serialization.JavaScriptSerializer.deserialize() before _loadFromDictionary and it still didn't work.
Thanks
0
Hello Roatin Marth,
Find below some sample code which works as expected at my side:
<asp:ScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadTreeView runat="server" ID="RadTreeView1">
<Nodes>
<telerik:RadTreeNode Text="Root" />
</Nodes>
</telerik:RadTreeView>
<script type="text/javascript">
function pageLoad(){
var treeView = $find("<%= RadTreeView1.ClientID %>");
var firstNode = treeView.get_nodes().getNode(0);
var jsonAsString = firstNode.toJsonString();
alert(jsonAsString);
var node = new Telerik.Web.UI.RadTreeNode();
node._loadFromDictionary(Sys.Serialization.JavaScriptSerializer.deserialize(jsonAsString));
firstNode.get_nodes().add(node);
}
</script>
What is different in your case?
Regards,
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Find below some sample code which works as expected at my side:
<asp:ScriptManager ID="RadScriptManager1" runat="server" />
<telerik:RadTreeView runat="server" ID="RadTreeView1">
<Nodes>
<telerik:RadTreeNode Text="Root" />
</Nodes>
</telerik:RadTreeView>
<script type="text/javascript">
function pageLoad(){
var treeView = $find("<%= RadTreeView1.ClientID %>");
var firstNode = treeView.get_nodes().getNode(0);
var jsonAsString = firstNode.toJsonString();
alert(jsonAsString);
var node = new Telerik.Web.UI.RadTreeNode();
node._loadFromDictionary(Sys.Serialization.JavaScriptSerializer.deserialize(jsonAsString));
firstNode.get_nodes().add(node);
}
</script>
What is different in your case?
Regards,
Albert
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.