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

Problems with DockPositionChanged

1 Answer 64 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Malichone
Top achievements
Rank 1
Malichone asked on 21 Jan 2010, 04:59 PM
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 { } 
            } 
        } 

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 26 Jan 2010, 11:15 AM
Hello Malichone,

I am not sure that I understand the problem clearly. Could you please send us a fully working sample project that demonstrates the issue? The source code that you have provided is not enough to determine the exact cause of the problem. Additionally you should consider the following:

The DockPositionChanged event is fired by every dock that changes its position, or index within the zone. This means that if a zone contains 3 docks and if the topmost one is dragged and dropped at the first index in another zone that contains 2 docks, the event will be fired 5 times. When the dock is dragged from the zone the other two docks will move an index up, which means they will change their position and fire the DockPositionChanged event. The other two docks in the dropping zone will move an index down which again will trigger the event. Practically the DockPositionChanged event will be fired for every single dock in these two zones. To demonstrate this I created a sample project (attached to the thread) that changes the Title when the dock changes its position. Drag the dock from the left-most zone and drop it in any of the remaining zones at the first index and you will notice that both docks will have their Titles changed.

Greetings,
Pero
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Dock
Asked by
Malichone
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or