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

Dock Index gets over written??

4 Answers 73 Views
Dock
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 06 Dec 2010, 12:45 PM
Hi, 

I currently have a page which has 8 docks spread between two docking zones. These are not dynamic and are coded into the page. My aim is to give the user the ability to save the position of the dock, it's collapse state and whether it viewable or not. everything works in that respect apart from one thing, the Index of the dock. I chose to use javascript (postbacks, update panels and web services were not an option) to save the state of the docks in a cookie when certain client side events fire, I then access this cookie on Page_Init and LoadDockLayout and apply to the relevant dock. when debugging in VS these events are hit and the information in the state is correct i.e. the index of the dock is the index that it should be. I have tried to manually set the index after calling ApplyState(), see below:
For Each dock As RadDock In RadDockLayout1.RegisteredDocks
                  Dim uniqueName As String = dock.UniqueName
                  Dim title As String = dock.Title
                  Dim index As Integer = dock.Index
                  Dim id As String = dock.ID
                  If Not (uniqueName = "") Then
                      Dim state As DockState = DockState.Deserialize(states(uniqueName).ToString())
                      dock.ApplyState(state)
                      Dim iIndex As Integer = state.Index
                      dock.Index = iIndex
                      Dim zone As String = state.DockZoneID
                      dock.DockZoneID = zone
                      dock.UniqueName = uniqueName
                      dock.Title = title
                      dock.EnableAnimation = True
                      dock.Width = Unit.Pixel(250)
                      dock.EnableRoundedCorners = True
                      dock.Style.Value = "margin-bottom: 10px !important;"
                  End If
 
              Next

Unfortunately for some reason the Index of the dock gets over written somewhere along the line and when the page loads the docks are all correct in terms of state apart from the order in which they appear in the dock zone's. For some reason the Index I set in the code behind gets over written with the index that it is on the markup page, below is a cut down example:

<telerik:RadDockZone ID="RadDockZone2" runat="server" Orientation="Vertical" Height="100%" >
      
                     
 
                        <telerik:RadDock ID="RadDock9" UniqueName="RadDock9" runat="server" Title="License Information" Width="250px" DockMode="Docked"
                            EnableAnimation="true" EnableRoundedCorners="true" Resizable="true" OnClientInitialize="DockInit" OnClientDockPositionChanged="OnDockChange" 
                    OnClientCommand="OnClientCommand" Style="margin-bottom: 10px !important;">
                            <ContentTemplate>
                                <uc8:license ID="license1" runat="server" />
                            </ContentTemplate>
                        </telerik:RadDock>
 
 
                        <telerik:RadDock ID="RadDock8" UniqueName="RadDock8" runat="server" Title="Sales Basket" Width="250px" DockMode="Docked"
                            EnableAnimation="true" EnableRoundedCorners="true" OnClientInitialize="DockInit" OnClientDockPositionChanged="OnDockChange"
                    OnClientCommand="OnClientCommand" Resizable="true" Style="margin-bottom: 10px !important;">
                            <ContentTemplate>
                                <uc10:SalesBasket ID="SalesBasket" runat="server" />
                            </ContentTemplate>
                        </telerik:RadDock>
</<telerik:RadDockZone>

In the code above if I were to set the index of RadDock8 to 0 and the index of RadDock9 to 1 it would load with RadDock9 with an index of 0 and Raddock8 with an index of 1. I have been through all the code and as already stated the correct index's are being passed and applied, but they just get over written somewhere and for some reason?

After looking at some other threads I can see that this was a bug in the past (http://www.telerik.com/community/forums/aspnet-ajax/docking/index-of-dockstate-not-persisting.aspx), has this been fixed now? Am I going about it the wrong way or missing something?

Regards

James

4 Answers, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 08 Dec 2010, 12:53 PM
Hi James,

If the correct index does not get applied to the RadDock please make sure your application implements the following approach:
  1. The DockState should be applied at Page_Init. So, please call the RadDock.ApplyState method in the Page.Init handler.
  2. You must handle the LoadDockLayout event of the RadDockLayout control, and populate the event args with the RadDock's Index and DockZoneID. The following is an example of how the args are populated if the docks were dynamically created:
    protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e)
    {
        //Populate the event args with the state information. The RadDockLayout control
        // will automatically move the docks according that information.
        foreach (DockState state in CurrentDockStates)
        {
            e.Positions[state.UniqueName] = state.DockZoneID;
            e.Indices[state.UniqueName] = state.Index;
        }
    }

If the problem persists, please open a new support ticket, and send us a simple project that demonstrates the issue.

Kind regards,
Pero
the Telerik team
Browse the vast support resources we have to jumpstart 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.
0
James
Top achievements
Rank 1
answered on 08 Dec 2010, 05:27 PM
Hi Pero,

Thank you for your answer, worked perfectly. Aadding the following line to the original code solved everything:

e.Indices(uniqueName) = iIndex

Many thanks

James
0
dileep
Top achievements
Rank 1
answered on 24 Mar 2011, 01:52 PM
Hi James,

Can you explain how have you implemented the suggested solution, as I am facing the same issue.
Where did you apply the
e.Indices(uniqueName) = iIndex

and how did you apply the RadDock.ApplyState. Is the 'iIndex'  value of DockZoneID index.


Thanks,
Dileep J
0
Pero
Telerik team
answered on 24 Mar 2011, 05:20 PM
Hello dileep,

I believe the following example might be of help: MyPortal demo.

Kind regards,
Pero
the Telerik team
Tags
Dock
Asked by
James
Top achievements
Rank 1
Answers by
Pero
Telerik team
James
Top achievements
Rank 1
dileep
Top achievements
Rank 1
Share this question
or