Problems with DockPositionChanged

2 posts, 0 answers
  1. Malichone
    Malichone avatar
    8 posts
    Member since:
    Nov 2009

    Posted 21 Jan 2010 Link to this post

    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.

    This is the master page that has the RadDockLayout
    <asp:UpdatePanel ID="upl_Content" runat="server" UpdateMode="Conditional" > 
          <telerik:RadDockLayout ID="RadDockLayout_Content" runat="server" onloaddocklayout="LoadDockLayout" onsavedocklayout="SaveDockLayout">   
             <asp:ContentPlaceHolder ID="ContentPlaceHolderContent" runat="server"></asp:ContentPlaceHolder> 

    Next we build the dockzone with all the available docks
    protected void Page_Init(object sender, EventArgs e) 
            private void GetWidgets() 
                if (WidgetList.Controls.Count == 0) 
                    ArrayList _wigetArray = new ArrayList(); 
                    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.DockPositionChanged += new DockPositionChangedEventHandler(RadDock_DockPositionChanged); 
                        dock.AutoPostBack = true
                        dock.Collapsed = true

    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) 
                        dock.DockZoneID = e.DockZoneID; 
                        dock.Collapsed = false
                        dock.statusPanel.Visible = true
                        dock.widgetPanel.Visible = true
                        DockCloseCommand _CloseCommand = new DockCloseCommand(); 
                        DockExpandCollapseCommand _ExpandCommand = new DockExpandCollapseCommand(); 
                        pm.CreateSaveStateTrigger(dock);  //save the dock state every time a dock is moved/altered. 
                    catch { } 

  2. Pero
    Pero avatar
    1156 posts

    Posted 26 Jan 2010 Link to this post

    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.

    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.
Back to Top