RadTreeview save expanded state without session object

9 posts, 0 answers
  1. Ramakrishna
    Ramakrishna avatar
    8 posts
    Member since:
    Apr 2014

    Posted 07 Jul 2014 Link to this post

    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
  2. Ramakrishna
    Ramakrishna avatar
    8 posts
    Member since:
    Apr 2014

    Posted 08 Jul 2014 Link to this post

    Still waiting for reply...

    RadTree - ExpandChildNodes() function doesn't work ?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 10 Jul 2014 Link to this post

    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
     

    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.

     
  5. Ramakrishna
    Ramakrishna avatar
    8 posts
    Member since:
    Apr 2014

    Posted 10 Jul 2014 in reply to Hristo Valyavicharski Link to this post

    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
  6. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 11 Jul 2014 Link to this post

    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 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.

     
  7. Ramakrishna
    Ramakrishna avatar
    8 posts
    Member since:
    Apr 2014

    Posted 14 Jul 2014 in reply to Hristo Valyavicharski Link to this post

     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

  8. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 14 Jul 2014 Link to this post

    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
     

    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.

     
  9. Ramakrishna
    Ramakrishna avatar
    8 posts
    Member since:
    Apr 2014

    Posted 14 Jul 2014 in reply to Hristo Valyavicharski Link to this post

    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>
  10. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 15 Jul 2014 Link to this post

    Ramakrishna,

    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017