Docking doesnt save the position

3 posts, 0 answers
  1. Frank Kocher
    Frank Kocher avatar
    7 posts
    Member since:
    Dec 2009

    Posted 05 Feb 2010 Link to this post


    i have created a dynamically docking control. At Page_Init (not Postback) I initialize the Docks. But when I move one of the docks every dock is in his start position in the dockingzone after postback, so I can't change the position of the single docks.

    ViewState is disabled.

    I hope someone can help me. Thx for help.

    <asp:UpdatePanel  runat="server" ID="UpdatePanel1"
                    <rad:RadDockLayout runat="server" ID="RadDockLayout1" OnSaveDockLayout="RadDockLayout1_SaveDockLayout" OnLoadDockLayout="RadDockLayout1_LoadDockLayout" > 
                        <rad:RadDockZone ID="RadDockZoneFelder" runat="server" /> 

    Private Property CurrentDockStates() As List(Of DockState) 
                    'Store the info about the added docks in the session. For real life 
                    ' applications we recommend using database or other storage medium 
                    ' for persisting this information. 
                    Dim _currentDockStates As List(Of DockState) = DirectCast(Session("CurrentDockStatesDynamicDocks"), List(Of DockState)) 
                    If [Object].Equals(_currentDockStates, NothingThen 
                        _currentDockStates = New List(Of DockState)() 
                        Session("CurrentDockStatesDynamicDocks") = _currentDockStates 
                    End If 
                    Return _currentDockStates 
                End Get 
                Set(ByVal value As List(Of DockState)) 
                    Session("CurrentDockStatesDynamicDocks") = value 
                End Set 
            End Property 
            Private Sub CreateSaveStateTrigger(ByVal dock As RadDock) 
                'Ensure that the RadDock control will initiate postback 
                ' when its position changes on the client or any of the commands is clicked. 
                'Using the trigger we will "ajaxify" that postback. 
                dock.AutoPostBack = True 
                dock.CommandsAutoPostBack = True 
                Dim saveStateTrigger As New AsyncPostBackTrigger() 
                saveStateTrigger.ControlID = dock.ID 
                saveStateTrigger.EventName = "DockPositionChanged" 
                saveStateTrigger = New AsyncPostBackTrigger() 
                saveStateTrigger.ControlID = dock.ID 
                saveStateTrigger.EventName = "Command" 
            End Sub 
            Private Function CreateRadDockFromState(ByVal state As DockState) As RadDock 
                Dim dock As New RadDock() 
                dock.DockMode = DockMode.Docked 
                dock.ID = String.Format("radDock{0}", state.UniqueName) 
                dock.Text = state.UniqueName 
                dock.Commands.Add(New DockCloseCommand()) 
                dock.Commands.Add(New DockExpandCollapseCommand()) 
                Return dock 
            End Function 
            Protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As ObjectByVal e As DockLayoutEventArgs) 
                'Populate the event args with the state information. The RadDockLayout control 
                ' will automatically move the docks according that information. 
                For Each state As DockState In CurrentDockStates 
                    e.Positions(state.UniqueName) = state.DockZoneID 
                    e.Indices(state.UniqueName) = state.Index 
            End Sub 
            Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As ObjectByVal e As DockLayoutEventArgs) 
                'Save the dock state in the page Session. This will enable us 
                ' to recreate the dock in the next Page_Init. 
                CurrentDockStates = RadDockLayout1.GetRegisteredDocksState() 
            End Sub 
            Protected Sub RadDock1_DockPositionChanged(ByVal sender As ObjectByVal e As DockPositionChangedEventArgs) 
                Dim dock As RadDock = DirectCast(sender, RadDock) 
                If e.DockZoneID = [String].Empty Then 
                    dock.Text = [String].Format("I used to be in {0} but now I am floating.", _ 
                    If dock.DockZoneID = [String].Empty Then 
                        dock.Text = "I used to be floating, but now I am docked in " + _ 
                    ElseIf dock.DockZoneID <> e.DockZoneID Then 
                        dock.Text = [String].Format("I moved from {0} to {1}.", _ 
                                                    dock.DockZoneID, e.DockZoneID) 
                        dock.Text = [String].Format("I moved from position {0} to position {1}.", _ 
                                                     dock.Index.ToString(), e.Index.ToString()) 
                    End If 
                End If 
                If Not Me.Session("liste_felder"Is Nothing Then 
                    Dim tobjListeFelder As ArrayList 
                    tobjListeFelder = Me.Session("liste_felder"
                End If 
            End Sub 
            ''' <summary> 
            ''' Seite initialisieren 
            ''' </summary> 
            Protected Sub Page_Init(ByVal sender As ObjectByVal e As System.EventArgs) Handles MyBase.Init 
                Me._id_produkt = Me.globalContext.QueryString("id_produkt"
                btnZurueck.url = Me.globalContext.URLContext.ermittleURL_AlleParameterAdmin(Me.globalContext.URLContext.id_seite, Me.globalContext.URLContext.id_seite, Me.globalContext.URLContext.id_vonmodul, -1, Me._id_produkt, -1, , , , , , , True"id_produkt="
                If Not Me.IsPostBack() Then 
                    Dim tAnzahl As Integer 
                    Dim tobjKonditionendefinitionenListe As New class_banken_produktdb_konditionendefinitionen_liste() 
                    ' Anzahl der schon definierten Felder ermitteln 
                    tAnzahl = tobjKonditionendefinitionenListe.ermittleAnzahlBeiProduktvonTab_banken_konditionendefinitionen(Me._id_produkt) 
                    ' Anzahl und Felder initialisieren 
                    If tAnzahl = 0 Then 
                        Me.Session.Add("anzahl_felder", 0) 
                        Me.Session.Add("liste_felder"New ArrayList()) 
                        Me.Session.Add("anzahl_felder", tAnzahl) 
                    End If 
                    ' Erzeugt die Controls 
                    ''Recreate the docks in order to ensure their proper operation 
                    Dim i As Integer = 0 
                    While i < CurrentDockStates.Count 
                        Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i)) 
                        'We will just add the RadDock control to the RadDockLayout. 
                        ' You could use any other control for that purpose, just ensure 
                        ' that it is inside the RadDockLayout control. 
                        ' The RadDockLayout control will automatically move the RadDock 
                        ' controls to their corresponding zone in the LoadDockLayout 
                        ' event (see below). 
                        'We want to save the dock state every time a dock is moved. 
                        System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1) 
                    End While 
                End If 
            End Sub 
            ''' <summary> 
            ''' Setzt die Liste mit den vorhanden Controls 
            ''' </summary> 
            Private Function setzeListeFelder() As ArrayList 
                Dim tobjListe As New ArrayList 
                Dim tobjKonditonendefinitionen As class_banken_produktdb_konditionendefinitionen 
                Dim tobjKonditionendefinitionenListe As New class_banken_produktdb_konditionendefinitionen_liste() 
                ' Alle vorhanden Definitionen ermitteln und die IDs als Liste zurückliefern, somit kann später ein 
                ' Abgleich gemacht werden ob die Definition schon in der DB ist oder nicht, d.h. neu geschrieben werden 
                ' muss oder nicht 
                For Each tobjKonditonendefinitionen In tobjKonditionendefinitionenListe 
                Return tobjListe 
            End Function 
            ''' <summary> 
            ''' Erzeugt den Inhalt für die dynamisch angelegten Felder 
            ''' </summary> 
            Private Sub erzeugeInhalte() 
                ' Erzeuge die Inhalte für die liste_felder 
                If Not Me.Session("liste_felder"Is Nothing Then 
                    For Each tid_definition As Integer In Me.Session("liste_felder"
                        Dim tobjRadDock As New RadDock() 
                        tobjRadDock.ID = "radDock" & tid_definition 
                        tobjRadDock.DockMode = DockMode.Docked 
                        tobjRadDock.UniqueName = tid_definition 
                        tobjRadDock.Title = tid_definition 
                        tobjRadDock.Text = tid_definition 
                        'tobjRadDock.AutoPostBack = True 
                        'AddHandler tobjRadDock.DockPositionChanged, AddressOf RadDock1_DockPositionChanged 
                End If 
            End Sub 

  2. Frank Kocher
    Frank Kocher avatar
    7 posts
    Member since:
    Dec 2009

    Posted 08 Feb 2010 Link to this post


    while debugging i found out that the LoadDockLayout event wil not be fired. The RadDockLayout1_SaveDockLayout event will be fired normal.

    I hope someone has any hint for me.

  3. Pero
    Pero avatar
    1156 posts

    Posted 09 Feb 2010 Link to this post

    Hello Frank,

    I examined your code and it seems that everything is OK. The docks are recreated on every postback, you are handling the LoadDockLayout event to place the docks at their correct position and zone, and you are saving the state in the Session. To overcome the issue try the following and in case the problem persists please open a new support ticket and send us a fully working project that recreates the error.
    • If the DockLayout is placed within a UserControl, which on the other hand is added dynamically in the Page_Load event, the LoadDockLayout event will not be triggered because it is fired immediately after the Page_Init event. The following help article describes the RadDock lifecycle: Please make sure that the user control is loaded before LoadDockLayout is fired i.e. in the Page_Init event.
    • Enable the ViewState on the RadDockLayout control

    Kind regards,
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top