Unable to change the size of a RadDock

3 posts, 0 answers
  1. Hunter
    Hunter avatar
    26 posts
    Member since:
    Aug 2012

    Posted 21 Feb 2013 Link to this post

    I am creating RadDocks dynamically.  Each RadDock is created with a custom control (ascx).  I have a RadDock command which displays a dialog in a RadWindow which allows me to change values in the custom control in the RadDock and also the size and title of the RadDock.  All this works except changing the size of the RadDock.  (I'm even able to change the title of the RadDock without a problem.)

    After the first creation of the RadDock, on postback the RadDocks are re-created in Page_Init using the Rad Dock states - and then I apply my new dock width after I apply the state.  What am I missing?
    Protected Sub Page_Load(sender As Object, e As System.EventArgs)
    If Not IsPostBack Then
    'CreateRadDock() routine is eventually called from here along with some other stuff that I don't think is relevant
    End If
    End Sub
    Protected Sub Page_Init(sender As Object, e As System.EventArgs)
    'Recreate the docks in order to ensure their proper operation
    If IsPostBack Then
    UpdateZone()
    End If
    End Sub
    Private Function CreateRadDock(Title As String, SectionCount As Integer) As RadDock
    Dim dock As New RadDock()
    dock.DockMode = DockMode.Docked
    dock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a")
    dock.ID = String.Format("RadDock{0}", dock.UniqueName)
    dock.Title = Title
    'dock.Text = String.Format("Added at {0}", DateTime.Now)
    dock.Width = Unit.Pixel(270 * SectionCount)
    dock.Resizable = True
    dock.Height = Unit.Pixel(400)
    dock.Skin = "Office2010Black"
    'RadAjaxManagerProxy1.AjaxSettings.AddAjaxSetting(dock, RadDockZone1, RadAjaxLoadingPanel1)
    AddHandler dock.Command, AddressOf dock_Command
    dock.Commands.Add(New DockCloseCommand())
    dock.Commands.Add(New DockExpandCollapseCommand())
    SetPropertiesCommand(dock)
    Return dock
    End Function
    Sub UpdateZone()
    RadDockZone1.Controls.Clear()
    Dim i As Integer = 0
    While i < CurrentDockStates.Count
    Dim dock As RadDock = CreateRadDockFromState(CurrentDockStates(i), i)
    RadDockLayout1.Controls.Add(dock)
    'We want to save the dock state every time a dock is moved.
    CreateSaveStateTrigger(dock)
    System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
    End While
    End Sub
    Private Function CreateRadDockFromState(state As DockState, PanelOrder As Integer) As RadDock
    Dim PanelID As String = String.Format("RadDock{0}", state.UniqueName)
    Dim panel As clsDashboardPanelMapItem = New clsDashboardPanelMapItem()
    panel = Session(PanelID)
    Dim properties As Hashtable = Session("properties_" & panel.PanelID & "_" & panel.SectionCount)
    Dim dock As New RadDock()
    dock.DockMode = DockMode.Docked
    dock.ID = PanelID
    dock.Skin = "Office2010Black"
    dock.ApplyState(state)
    dock.Width = Unit.Pixel(270 * properties("PanelCount"))
    dock.Height = Unit.Pixel(400)
    dock.Title = properties("PanelTitle")
    'Load the custom control
    Dim UserControl As Control = SetSection(panel.PanelModulePath, properties("PanelTitle"), panel.PanelDesc, properties, Nothing, properties("PanelCount"), panel.PanelID, panel.SectionCount, panel.ObjectName)
    dock.ContentContainer.Controls.Add(UserControl)
    AddHandler dock.Command, AddressOf dock_Command
    dock.Commands.Add(New DockCloseCommand())
    dock.Commands.Add(New DockExpandCollapseCommand())
    SetPropertiesCommand(dock)
    Return dock
    End Function
    Private Sub CreateSaveStateTrigger(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
    End Sub
    Sub SetPropertiesCommand(dock As RadDock)
    Dim propCmd As DockCommand = New DockCommand()
    propCmd.Name = "Properties"
    propCmd.Text = "Properties"
    propCmd.CssClass = "DockPropertiesCommand"
    propCmd.AutoPostBack = True
    dock.Commands.Insert(0, propCmd)
    End Sub

    <telerik:RadDockLayout ID="RadDockLayout1" runat="server" Skin="Default" OnSaveDockLayout="RadDockLayout1_SaveDockLayout"
        OnLoadDockLayout="RadDockLayout1_LoadDockLayout" StoreLayoutInViewState="True">
        <telerik:RadDockZone ID="RadDockZone1" runat="server" Height="1400px" Width="1100px" Skin="Black" Orientation="Horizontal">
     
        </telerik:RadDockZone>
    </telerik:RadDockLayout>

    Any help is appreciated. Thanks.

  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 26 Feb 2013 Link to this post

    Hello Hunter,

    The size is not changed because the values of the properties Width and Height are overridden by the client state of the dock, which is applied after the Init event of the page. Please set the properties on Page_Load and the dock should be resized correctly.

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hunter
    Hunter avatar
    26 posts
    Member since:
    Aug 2012

    Posted 26 Feb 2013 Link to this post

    Great that worked.  Thanks.
Back to Top