Unable to move docks

4 posts, 0 answers
  1. Martin
    Martin avatar
    12 posts
    Member since:
    Jul 2010

    Posted 21 Nov 2011 Link to this post

    I am dynamically creating docks when a user clicks a button, inside the dock will be various controls depending on what "page widget" the user has selected from the dropdown list.

    I have started off with the simplest "page widget", a RadEditor and a Textbox.

    I can persist any data entered into the controls by saving it to a session and re-populate the various controls, however I need to be able to move the docks around so that the order of the "page widgets" can be changed easily but I've lost this functionality, I cannot move, collapse or remove them.

    I have simplified the code down to the basics to make it easier to read.

    Any ideas? Thanks




    (I don't care about the docks open/close state, collapsing will be removed)


    ASPX
    <asp:Button ID="btnAdd" runat="server" Text="Add a widget" />
    <br />
    <br />
    <telerik:RadDockLayout ID="rdDockLayout" runat="server">
        <telerik:RadDockZone ID="rdDockZone" runat="server" Width="700px">
     
        </telerik:RadDockZone>
    </telerik:RadDockLayout>

    VB
    Imports Telerik.Web.UI
     
    Partial Class Admin_DockTest2
        Inherits System.Web.UI.Page
     
        Dim DockStore As New List(Of DockSaved)
     
        ''' <summary>
        ''' Container to hold a saved dock so it can be brought back in to dock zone on postback etc.
        ''' </summary>
        Private Structure DockSaved
            Property Key As Integer
            Property WidgetObject As PageWidgets
            Property dID As String
     
            Public Sub New(WidgetTypeID As Integer, Widget As PageWidgets, dockID As String)
                Key = WidgetTypeID
                WidgetObject = Widget
                dID = dockID
            End Sub
        End Structure
     
        Protected Sub Page_Init(sender As Object, e As System.EventArgs) Handles Me.Init
            If Not Session("Widgets") Is Nothing Then
                DockStore = CType(Session("Widgets"), List(Of DockSaved))
            End If
        End Sub
     
        Protected Sub btnAdd_Click(sender As Object, e As System.EventArgs) Handles btnAdd.Click
            AddWidget()
        End Sub
     
        Private Sub AddWidget()
            CreateDock(1) 'type 1
        End Sub
     
        Private Sub CreateDock(WidgetType As Integer)
            Dim randID As String = Guid.NewGuid().ToString.Replace("-", "a")
     
            Dim dock As New RadDock
            dock.ID = "dk" + WidgetType.ToString() + "-" + randID
            dock.Title = "dk" + WidgetType.ToString() + DateTime.Now.ToShortTimeString
            dock.ClientIDMode = UI.ClientIDMode.Static
            dock.Commands.Add(New DockExpandCollapseCommand())
            dock.Commands.Add(New DockCloseCommand())
     
            dock.AutoPostBack = True
            dock.EnableDrag = True
     
            Dim rdTextboxID = "tb" + randID
            Dim rdTextbox As RadTextBox = GetRadTextbox(rdTextboxID)
            rdTextbox.Text = "help!"
     
            Dim rdEditorID As String = "rdEditor" + randID
            Dim rdEditor As RadEditor = GetRadEditor(rdEditorID)
     
            dock.ContentContainer.Controls.Add(rdTextbox)
            dock.ContentContainer.Controls.Add(rdEditor)
     
            rdDockLayout.Controls.Add(dock)
            dock.Dock(rdDockZone)
        End Sub
     
        Protected Sub rdDockLayout_SaveDockLayout(sender As Object, e As Telerik.Web.UI.DockLayoutEventArgs) Handles rdDockLayout.SaveDockLayout
            If rdDockZone.Docks.Count > 0 Then
     
                'Clear current entries to avoid saving duplicates
                DockStore.Clear()
     
                For Each d In rdDockZone.Docks
                    Dim dID As String = d.ID
                    Dim randID As String = d.ID.Substring(4)
                    Dim WidgetTypeID As Integer = 1
     
                    Select Case WidgetTypeID
                        Case 1  '>>>>> Widget Type: WidgetHTML
                            Dim tbID As String = "tb" + randID
                            Dim rdTextbox As RadTextBox = CType(d.ContentContainer.FindControl(tbID), RadTextBox)
     
                            Dim rdEditorID As String = "rdEditor" + randID
                            Dim rdEditor As RadEditor = CType(d.ContentContainer.FindControl(rdEditorID), RadEditor)
     
                            Dim widget As New WidgetHTML
     
                            'Populate a widget
                            widget.SchemeID = 2
                            widget.Title = rdTextbox.Text
                            widget.HTML = rdEditor.Content
                            widget.Visible = True
     
                            'save widget
                            Dim ds As New DockSaved(1, widget, dID)
                            DockStore.Add(ds)
     
                        Case 2 '>>>>> Widget Type: .......
     
                    End Select
                Next
            End If
     
            Session("Widgets") = DockStore
        End Sub
     
        Protected Sub rdDockLayout_LoadDockLayout(sender As Object, e As Telerik.Web.UI.DockLayoutEventArgs) Handles rdDockLayout.LoadDockLayout
            If DockStore.Count > 0 Then
                For Each w In DockStore
                    Dim widgy As WidgetHTML = CType(w.WidgetObject, WidgetHTML)
     
                    Dim dock As New RadDock
                    dock.ID = w.dID
                    dock.Title = "dk - returned"
                    dock.ClientIDMode = UI.ClientIDMode.Static
                    dock.Commands.Add(New DockExpandCollapseCommand())
                    dock.Commands.Add(New DockCloseCommand())
     
                    dock.AutoPostBack = True
                    dock.EnableDrag = True
     
                    Dim randID As String = w.dID.Substring(4)
     
                    'if type 1
                    Dim rdEditorID As String = "rdEditor" + randID
     
                    Dim rdTextboxID = "tb" + randID
                    Dim rdTextbox As RadTextBox = GetRadTextbox(rdTextboxID)
                    rdTextbox.Text = widgy.Title
     
                    Dim rdEditor As RadEditor = GetRadEditor(rdEditorID)
                    rdEditor.Content = widgy.HTML
     
                    dock.ContentContainer.Controls.Add(rdTextbox)
                    dock.ContentContainer.Controls.Add(rdEditor)
     
                    rdDockLayout.Controls.Add(dock)
                    dock.Dock(rdDockZone)
                Next
            End If
        End Sub
     
        ''' <summary>
        ''' HTML components to build WebWidgets.
        ''' </summary>
        ''' <param name="WidgetName">Desired ID of the control.</param>
        ''' <returns>Returns the control requested with the correct ID.</returns>
    #Region "Widgets"
     
        Private Function GetRadTextbox(WidgetName As String) As RadTextBox
            Dim rdTextbox As New RadTextBox
            rdTextbox.ID = WidgetName
            rdTextbox.ClientIDMode = UI.ClientIDMode.Static
            rdTextbox.Skin = "Windows7"
     
            Return rdTextbox
        End Function
     
        Private Function GetRadEditor(WidgetName As String) As RadEditor
            Dim rdEditor As New RadEditor
            rdEditor.ID = WidgetName
            rdEditor.ClientIDMode = UI.ClientIDMode.Static
            rdEditor.Skin = "Windows7"
     
            Return rdEditor
        End Function
     
    #End Region
     
    End Class









  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 23 Nov 2011 Link to this post

    Hi Martin,

    I have already provided a response to your question in the support ticket that you opened. Please use it for further discussions on the problem at hand.

    When reporting issues and requesting assistance in the future, I would suggest using separate support tickets for a particular problem. This will make our correspondence much easier to track. Also, note that our support plan includes guaranteed response time for the support tickets only, while a post in the Support Forums doesn't guarantee you a response from the Telerik support team. This is why I would suggest sending a support ticket, when you want to report a problem that is more urgent and needs additional attention, as you have done already.

    Regards,
    Slav
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Martin
    Martin avatar
    12 posts
    Member since:
    Jul 2010

    Posted 24 Nov 2011 Link to this post

    I have located the problem, it seems that setting the ClientIDMode of the dock to static was causing an issue, as soon as this was removed the dock commands started to work instantly.

    Fixed.
  5. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 25 Nov 2011 Link to this post

    Hi Martin,

    I am very happy that you have resolved the issue at hand!

    Indeed this behavior is expected when using ClientIDMode set to Static. It is recommended by Microsoft to use this mode only for static controls.The RadControls are controls with complex hierarchies of child controls and templates so setting their ClientIDMode property to Static will break their functionality. I would recommend not using ClientIdMode Static for any Telerik control.

    Kind regards,
    Slav
    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
Back to Top