The setup we have is this: we have a DockZone filled with collapsed docks that the user drags out to one of three main dockZones on the page. When the dock is dropped into the new zone we are firing the DockPositionChanged event. This event flushes out the dock with all of the controls that it needs and loads the usercontrol into the dock. What we are seeing is whenever any event is triggered, the usercontrol inside the dock does an asynpostback or the expandCollapse event is fired so to is the DockPositionChanged event. Also we would really want the master list per say of docks to be repopulated with a fresh copy of the dock that was just dragged out and placed into one of the three zones.
CODE:
This is the master page that has the RadDockLayout
<asp:UpdatePanel ID="upl_Content" runat="server" UpdateMode="Conditional" > |
<ContentTemplate> |
<telerik:RadDockLayout ID="RadDockLayout_Content" runat="server" onloaddocklayout="LoadDockLayout" onsavedocklayout="SaveDockLayout"> |
<asp:ContentPlaceHolder ID="ContentPlaceHolderContent" runat="server"></asp:ContentPlaceHolder> |
</telerik:RadDockLayout> |
</ContentTemplate> |
<Triggers> |
</Triggers> |
</asp:UpdatePanel> |
Next we build the dockzone with all the available docks
protected void Page_Init(object sender, EventArgs e) |
{ |
GetWidgets(); |
} |
private void GetWidgets() |
// POPULATE WIDGET SELECTION ZONE |
{ |
if (WidgetList.Controls.Count == 0) |
{ |
ArrayList _wigetArray = new ArrayList(); |
_wigetArray.Add("~/Prototype/Modules/CriticalPrinters/CriticalPrinters.ascx"); |
_wigetArray.Add("~/Prototype/Modules/CriticalPrinters/CriticalPrinters.ascx"); |
_wigetArray.Add("~/Prototype/Modules/SMIncidentAge/Services/SMIncidentAge.ascx"); |
_wigetArray.Add("~/Prototype/Modules/Weather/WeatherControl.ascx"); |
int i = 0; |
foreach (String widgetURL in _wigetArray) |
{ |
NCSBlackRadDock dock = new NCSBlackRadDock(); |
dock.widgetIcon.ImageUrl = "~/Prototype/Modules/HttpWebRequest/Images/Config.png"; |
dock.WidgetTitle.Text = string.Format("RadDock{0}", i); |
dock.Tag = widgetURL; |
dock.ID = string.Format("RadDock{0}", i); |
dock.UniqueName = Guid.NewGuid().ToString(); |
dock.Text = dock.ID.ToString(); |
dock.statusPanel.Visible = false; |
dock.widgetPanel.Visible = false; |
dock.EnableViewState = false; |
dock.Commands.Remove(dock.CloseCommand); |
dock.Commands.Remove(dock.ExpandCommand); |
dock.Commands.Remove(dock.SettingsCommand); |
dock.DockPositionChanged += new DockPositionChangedEventHandler(RadDock_DockPositionChanged); |
dock.AutoPostBack = true; |
dock.Collapsed = true; |
WidgetList.Controls.Add(dock); |
i++; |
} |
} |
} |
Then finally the RadDock_DockPositionChanged
protected void RadDock_DockPositionChanged(object sender, DockPositionChangedEventArgs e) |
{ |
Site1 pm = (Site1)Page.Master.Master; |
NCSBlackRadDock dock = (NCSBlackRadDock)sender; |
if (dock.DockZoneID != e.DockZoneID) |
{ |
try |
{ |
dock.DockZoneID = e.DockZoneID; |
dock.Collapsed = false; |
dock.statusPanel.Visible = true; |
dock.widgetPanel.Visible = true; |
DockCloseCommand _CloseCommand = new DockCloseCommand(); |
DockExpandCollapseCommand _ExpandCommand = new DockExpandCollapseCommand(); |
dock.Commands.Add(_CloseCommand); |
dock.Commands.Add(_ExpandCommand); |
dock.Commands.Remove(dock.PreviewCommand); |
LoadWidget(dock); |
pm.CreateSaveStateTrigger(dock); //save the dock state every time a dock is moved/altered. |
} |
catch { } |
} |
} |