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

Dynamic RadDock-structure only keeps track of non-dynamic RadDockZone

3 Answers 58 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Christoffer Rosenqvist
Top achievements
Rank 1
Christoffer Rosenqvist asked on 30 Oct 2009, 01:01 PM
I have a .aspx page where I have a RadDockLayout and a RadDockZone registered as this:
<telerik:RadDockLayout ID="rdlDockLayout" runat="server" OnLoadDockLayout="rdlDockLayout_LoadDockLayout" 
    OnSaveDockLayout="rdlDockLayout_SaveDockLayout"
    <telerik:RadDockZone ID="rdzMain" UniqueName="rdzMain" runat="server" MinHeight="600px" 
        Width="550px" BorderStyle="None"
    </telerik:RadDockZone> 
    <div style="display: none"
        <%--Hidden UpdatePanel, which is used to receive the new dock controls.--%> 
        <%--We will move them with script to the desired initial dock zone.--%> 
        <asp:UpdatePanel runat="server" ID="udpPanel" OnLoad="udpPanel_Load"
            <Triggers> 
                <asp:AsyncPostBackTrigger ControlID="cmdNewDockWithZone" EventName="Click" /> 
                <asp:AsyncPostBackTrigger ControlID="cmdNewDock" EventName="Click" /> 
            </Triggers> 
        </asp:UpdatePanel> 
    </div> 
</telerik:RadDockLayout> 

I'm adding new Docks to the page via the UpdatePanel and placing the using script as illustrated in this example. Some docks are created with a DockZone and some are placed in these dynamically created DockZones.

Now I want to be able to react to the placed docks from code behind during the AJAX call backs but it seems that the DockZones are "lost" after they have been created. I.e. only the non-dynamic DockZone (rdzMain) is registered in rdlDockLayout.RegisteredZones and when calling rdlDockLayout.GetRegisteredDocksState() all Docks that are docked in dynamically created DockZones have an empty string for DockZoneID. This makes it hard to figure out which Dock belongs to which DockZone, which is important to my application.

DockZones have the same string (unique per DockZone though) set as both ID and UniqueName.

Is something wrong or is this the expected behavior when creating DockZones dynamically?


3 Answers, 1 is accepted

Sort by
0
Christoffer Rosenqvist
Top achievements
Rank 1
answered on 30 Oct 2009, 03:57 PM
As per this post I'm using the following code to add DockZones to Docks:
private void AddTargetGroupDockZone(RadDock dock) { 
    RadDockZone dockZone = CreateDockZone(); 
    dockZone.MinHeight = Unit.Pixel(40); 
    dockZone.Height = Unit.Percentage(100); 
    dockZone.Width = Unit.Pixel(500); 
    dock.ContentContainer.Controls.Add(dockZone); 
private RadDockZone CreateDockZone() { 
    RadDockZone dockZone = new RadDockZone(); 
    dockZone.UniqueName = string.Format(DockZoneIDFormat, Guid.NewGuid()); 
    dockZone.ID = dockZone.UniqueName; 
    dockZone.BorderStyle = BorderStyle.None; 
    return dockZone; 

At no time do I add the dynamic DockZones to the RadDockLayout, from code behind or via client script, and I don't save any kind of DockZone-state as I do with the Docks. Might this be a reason? Is there som client-side API that should be used with DockZones to add them to the RadDockLayout so they get registered in the RegisteredZones or can't this be done dynamically?


0
Christoffer Rosenqvist
Top achievements
Rank 1
answered on 02 Nov 2009, 02:39 PM
The key to solving this problem seems to be to add the dockzone to the dock everytime you recreate it in the Page.Init method. I do this by having a Dictionary where I store the Dock.ID as key and the DockZone.ID as value. Then when I recreate the Dock from state I check if the Dock.ID is in the key collection of the Dictionary. If it is I get the DockZone.ID from the Dictionary value collection and recreate a DockZone and add it to the Dock.ContentContainer.Controls-collection.
0
AndyRutter
Top achievements
Rank 2
answered on 09 Nov 2009, 12:25 PM
Hi there,
Any chance of supplying a sample of the code you are using to do this?

Cheers
Brian
Tags
Dock
Asked by
Christoffer Rosenqvist
Top achievements
Rank 1
Answers by
Christoffer Rosenqvist
Top achievements
Rank 1
AndyRutter
Top achievements
Rank 2
Share this question
or