This is a migrated thread and some comments may be shown as answers.

Creating a dock with initial parent as RadDockLayout

1 Answer 68 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 14 Jun 2011, 10:56 PM
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;
}
else
{
    RadDockLayout dockLayout = Parent as RadDockLayout;
    RadDockZone zone = dockLayout.RegisteredZones.Where(registeredZone => registeredZone.ID == DockZoneID).FirstOrDefault();
    pane = zone.Parent as RadPane;
}
 
try
{
    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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 17 Jun 2011, 12:00 PM
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:
RadDockLayout1.Controls.Add(dock);
dock.Dock(zone);

Kind regards,
Pero
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.

Tags
Dock
Asked by
Sean
Top achievements
Rank 2
Answers by
Pero
Telerik team
Share this question
or