Ramakrishna
Top achievements
Rank 1
Ramakrishna
asked on 07 Jul 2014, 09:18 PM
I have a RadTree controls in a single page divided by tabs, 1st tab two radtrees, 2nd tab three, 3rd tab three.
Child nodes are expanding LoadOnDemand event.
I gonna maintain Tree view state(without session) though user refresh the page. If user expands parent node and press F5 button we have to show expanded nodes as it is.
Private Shared dictOriginTree As New Dictionary(Of String, Boolean)
Protected Sub rtvOriginTree_NodeExpand(sender As Object, e As RadTreeNodeEventArgs)
If Not dictOriginTree.ContainsKey(e.Node.UniqueID) Then
dictOriginTree.Add(e.Node.UniqueID, e.Node.Expanded)
End If
End Sub
Protected Sub ramMasterDocumentsAjaxManager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
Dim node As RadTreeNode
For Each node In rtvOriginTree.GetAllNodes()
If dictOriginTree.ContainsKey(node.UniqueID) Then
node.ExpandParentNodes()
node.ExpandChildNodes()
node.Expanded = dictOriginTree.Item(node.UniqueID.ToString())
node.ExpandMode = TreeNodeExpandMode.ServerSide
End If
Next
End Sub
Child nodes are expanding LoadOnDemand event.
I gonna maintain Tree view state(without session) though user refresh the page. If user expands parent node and press F5 button we have to show expanded nodes as it is.
Private Shared dictOriginTree As New Dictionary(Of String, Boolean)
Protected Sub rtvOriginTree_NodeExpand(sender As Object, e As RadTreeNodeEventArgs)
If Not dictOriginTree.ContainsKey(e.Node.UniqueID) Then
dictOriginTree.Add(e.Node.UniqueID, e.Node.Expanded)
End If
End Sub
Protected Sub ramMasterDocumentsAjaxManager_AjaxRequest(ByVal sender As Object, ByVal e As Telerik.Web.UI.AjaxRequestEventArgs)
Dim node As RadTreeNode
For Each node In rtvOriginTree.GetAllNodes()
If dictOriginTree.ContainsKey(node.UniqueID) Then
node.ExpandParentNodes()
node.ExpandChildNodes()
node.Expanded = dictOriginTree.Item(node.UniqueID.ToString())
node.ExpandMode = TreeNodeExpandMode.ServerSide
End If
Next
End Sub
8 Answers, 1 is accepted
0
Ramakrishna
Top achievements
Rank 1
answered on 08 Jul 2014, 02:32 PM
Still waiting for reply...
RadTree - ExpandChildNodes() function doesn't work ?
RadTree - ExpandChildNodes() function doesn't work ?
0
Hi Ramakrishna,
I have replied to your question in this forum post: http://www.telerik.com/forums/radtreeview-save-expanded-state#JMXlJa0_2068gUaNW-7sEg
Regards,
Hristo Valyavicharski
Telerik
I have replied to your question in this forum post: http://www.telerik.com/forums/radtreeview-save-expanded-state#JMXlJa0_2068gUaNW-7sEg
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ramakrishna
Top achievements
Rank 1
answered on 10 Jul 2014, 01:45 PM
Hi Hristo,
Thank you very much for your reply.I gone through the Demo and saw the code but in the code Session object being used. My questions are
1) Is it possible without using Session
2) In my case i have total of 7 RadTreeView controls in a single page. So i should use 7 different Session objects ? Absolutely it will hit the performance.
I will attach screen shots.
Protected Sub SaveButton_Click(sender As Object, e As EventArgs)
Session("CustomPersistenceSettingsKey") = Me.Session.SessionID
Dim fileId As String = Session("CustomPersistenceSettingsKey").ToString()
LoadButton.Enabled = True
RadPersistenceManager1.StorageProviderKey = fileId
RadPersistenceManager1.SaveState()
End Sub
Thank you very much for your reply.I gone through the Demo and saw the code but in the code Session object being used. My questions are
1) Is it possible without using Session
2) In my case i have total of 7 RadTreeView controls in a single page. So i should use 7 different Session objects ? Absolutely it will hit the performance.
I will attach screen shots.
Protected Sub SaveButton_Click(sender As Object, e As EventArgs)
Session("CustomPersistenceSettingsKey") = Me.Session.SessionID
Dim fileId As String = Session("CustomPersistenceSettingsKey").ToString()
LoadButton.Enabled = True
RadPersistenceManager1.StorageProviderKey = fileId
RadPersistenceManager1.SaveState()
End Sub
0
Hi Ramakrishna,
The session object is used only for the purpose of the demo. The RadPersistenceFramework stores its data in a xml file. In your scenario you could set the
Regards,
Hristo Valyavicharski
Telerik
The session object is used only for the purpose of the demo. The RadPersistenceFramework stores its data in a xml file. In your scenario you could set the
CustomPersistenceSettingsKey
to be the UserID (value retrieved from the DB). Or you can use Cookies instead of Session.Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ramakrishna
Top achievements
Rank 1
answered on 14 Jul 2014, 01:37 PM
Hi Hristo,
I tried several options but it didn't work. here is the code, could you help me out.
aspx code:
--------------
<telerik:RadPersistenceManager runat="server" ID="RadPersistenceManager1">
<PersistenceSettings>
<telerik:PersistenceSetting ControlID="rtvOriginTree" />
</PersistenceSettings>
</telerik:RadPersistenceManager>
<telerik:RadTreeView ID="rtvOriginTree" runat="server" DataFieldID="ID" EnableDragAndDrop="true" OnNodeExpand="rtvOriginTree_NodeExpand"
DataFieldParentID="ParentID" DataTextField="NodeText" DataValueField="ID" OnClientContextMenuShowing="onClientContextMenuShowing"
OnClientContextMenuItemClicked="OnClientContextMenuItemClicked_P1" OnClientNodeClicking="ClientNodeClicking_OD"
OnSaveCustomSettings="rtvOriginTree_SaveCustomSettings" OnLoadCustomSettings="rtvOriginTree_LoadCustomSettings"
Skin="Windows7" Style="white-space: normal;" ShowLineImages="false">
</telerik:RadTreeView>
VB Code:
--------
Protected Sub rtvOriginTree_SaveCustomSettings(sender As Object, e As Telerik.Web.UI.PersistenceManagerSaveStateEventArgs)
e.CustomSettings.Add(New Telerik.Web.UI.ControlSetting() With { _
.Name = "pos", _
.Value = wndStateHolder.Value _
})
End Sub
Protected Sub rtvOriginTree_NodeExpand(sender As Object, e As RadTreeNodeEventArgs)
RadPersistenceManager1.StorageProviderKey = CurrentSession.UserId.ToString()
RadPersistenceManager1.SaveState()
End Sub
I tried several options but it didn't work. here is the code, could you help me out.
aspx code:
--------------
<telerik:RadPersistenceManager runat="server" ID="RadPersistenceManager1">
<PersistenceSettings>
<telerik:PersistenceSetting ControlID="rtvOriginTree" />
</PersistenceSettings>
</telerik:RadPersistenceManager>
<telerik:RadTreeView ID="rtvOriginTree" runat="server" DataFieldID="ID" EnableDragAndDrop="true" OnNodeExpand="rtvOriginTree_NodeExpand"
DataFieldParentID="ParentID" DataTextField="NodeText" DataValueField="ID" OnClientContextMenuShowing="onClientContextMenuShowing"
OnClientContextMenuItemClicked="OnClientContextMenuItemClicked_P1" OnClientNodeClicking="ClientNodeClicking_OD"
OnSaveCustomSettings="rtvOriginTree_SaveCustomSettings" OnLoadCustomSettings="rtvOriginTree_LoadCustomSettings"
Skin="Windows7" Style="white-space: normal;" ShowLineImages="false">
</telerik:RadTreeView>
VB Code:
--------
Protected Sub rtvOriginTree_SaveCustomSettings(sender As Object, e As Telerik.Web.UI.PersistenceManagerSaveStateEventArgs)
e.CustomSettings.Add(New Telerik.Web.UI.ControlSetting() With { _
.Name = "pos", _
.Value = wndStateHolder.Value _
})
End Sub
Protected Sub rtvOriginTree_NodeExpand(sender As Object, e As RadTreeNodeEventArgs)
RadPersistenceManager1.StorageProviderKey = CurrentSession.UserId.ToString()
RadPersistenceManager1.SaveState()
End Sub
0
Ramakrishna,
What happened? Do you see the generated file in the App_Data folder? Does it contain any data? How do you restore saved data?
Regards,
Hristo Valyavicharski
Telerik
What happened? Do you see the generated file in the App_Data folder? Does it contain any data? How do you restore saved data?
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0
Ramakrishna
Top achievements
Rank 1
answered on 14 Jul 2014, 03:26 PM
yup, i could see a file in App_Data. but not sure how to restore data.
<?xml version="1.0"?>
<ArrayOfRadControlState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RadControlState>
<ControlSettings />
<UniqueId>Telerik.Web.UI_PersistanceManager_CustomSettings</UniqueId>
</RadControlState>
<RadControlState>
<ControlSettings>
<ControlSetting>
<Name>CheckedIndices</Name>
<Value Type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">
<ArrayOfString />
</Value>
</ControlSetting>
<ControlSetting>
<Name>ExpandedIndices</Name>
<Value Type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">
<ArrayOfString>
<string>0</string>
<string>0:1</string>
</ArrayOfString>
</Value>
</ControlSetting>
<ControlSetting>
<Name>SelectedIndices</Name>
<Value Type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">
<ArrayOfString>
<string>0:2</string>
</ArrayOfString>
</Value>
</ControlSetting>
</ControlSettings>
<UniqueId>ctl00$BodyContentPlaceholder$rtvOriginTree</UniqueId>
</RadControlState>
</ArrayOfRadControlState>
<?xml version="1.0"?>
<ArrayOfRadControlState xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<RadControlState>
<ControlSettings />
<UniqueId>Telerik.Web.UI_PersistanceManager_CustomSettings</UniqueId>
</RadControlState>
<RadControlState>
<ControlSettings>
<ControlSetting>
<Name>CheckedIndices</Name>
<Value Type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">
<ArrayOfString />
</Value>
</ControlSetting>
<ControlSetting>
<Name>ExpandedIndices</Name>
<Value Type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">
<ArrayOfString>
<string>0</string>
<string>0:1</string>
</ArrayOfString>
</Value>
</ControlSetting>
<ControlSetting>
<Name>SelectedIndices</Name>
<Value Type="System.Collections.Generic.List`1[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]">
<ArrayOfString>
<string>0:2</string>
</ArrayOfString>
</Value>
</ControlSetting>
</ControlSettings>
<UniqueId>ctl00$BodyContentPlaceholder$rtvOriginTree</UniqueId>
</RadControlState>
</ArrayOfRadControlState>
0
Ramakrishna,
In order to preserved selected nodes, you will have to store and restore saved data. For additional information please look at these links:
Regards,
Hristo Valyavicharski
Telerik
In order to preserved selected nodes, you will have to store and restore saved data. For additional information please look at these links:
I hope this helps.
Regards,
Hristo Valyavicharski
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.