Creating a dock with initial parent as RadDockLayout

2 posts, 1 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 14 Jun 2011 Link to this post

    Hi Telerik,

    I noticed something weird going on with my code and I was wondering if there was a way to avoid this scenario.

    When I create a RadDock I attach it to a RadDockZone via "RadDockZone.Controls.Add(dock)". This sets the RadDock's Parent to RadDockZone.

    When I recreate a RadDock on Page_Init, I allowed the RadDockLayout to move the RadDock into place during RadDockLayout_LoadDockLayout. This sets the RadDock's parent to RadDockLayout.

    Thus, this code is necessary and I would like to condense it into something more sensible:

    //The dock's parent can change. When it is first created the dock's parent is the DockZone, but after
    //recreation the dock's parent is RadDockLayout.
    RadPane pane = null;
    if (Parent.GetType() == typeof(CormantRadDockZone))
        pane = Parent.Parent as RadPane;
        RadDockLayout dockLayout = Parent as RadDockLayout;
        RadDockZone zone = dockLayout.RegisteredZones.Where(registeredZone => registeredZone.ID == DockZoneID).FirstOrDefault();
        pane = zone.Parent as RadPane;
        Chart.Height = new Unit(pane.Height.Value - 42, UnitType.Pixel);
        Chart.Width = new Unit(pane.Width.Value - 22, UnitType.Pixel);
    catch (Exception ex)
        Logger.ErrorFormat("Unable to adjust chart dimensions. Reason: {0}", ex.Message);

    Is my problem clear? How can I avoid this?
  2. Answer
    Pero avatar
    1156 posts

    Posted 17 Jun 2011 Link to this post

    Hello Sean,

    You could always add the dock to the RadDockLayout and then dock it to the respective zone using the RadDock.Dock server-side method. When the dock is recreated it has to be added to the RadDockLayout so that it can be positioned in the correct zone.
    The code that moves the dock to the zone should look like the following:

    Kind regards,
    the Telerik team

    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Back to Top