Dynamically generating zones and docks

6 posts, 0 answers
  1. Adrian
    Adrian avatar
    81 posts
    Member since:
    Aug 2006

    Posted 06 May 2009 Link to this post

    Hi there,

    Has anyone got any examples of dynamically adding/removing zones and docks which are persisted on postback. There are many examples showing docks only but nothing on zones. I basically need to create something similar to this example

    http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx

    but with the addition of being able to dynamically add or remove zones.

    Many thanks

    Ady



  2. Adrian
    Adrian avatar
    81 posts
    Member since:
    Aug 2006

    Posted 07 May 2009 Link to this post

    I think ive got it sorted now actually. I needed to convert the ReadOnlyCollection of registered zones into a generic list

    List<RadDockZone> zones = new List<RadDockZone>(RadDockLayout1.RegisteredZones); 

    and i could then follow the example of dyanamically adding docks.

    Ady
  3. Adrian
    Adrian avatar
    81 posts
    Member since:
    Aug 2006

    Posted 07 May 2009 Link to this post

    .
  4. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 11 May 2009 Link to this post

    List

     

    <RadDockZone> zones = new List<RadDockZone>(RadDockLayout1.RegisteredZones);

     

     

    foreach (RadDockZone zone in zones)

     

    {

     

        string currentZoneID = zone.ID;

     

    }



    The RadDock control doesn't have a mechanism for the state of the RadDockZones, so you should create your own mechanism for preserving the state of the dynamically created RadDockZones.
    The code below is related to the RadDocks state:

     

    List<DockState> CurrentDockStates = RadDockLayout1.GetRegisteredDocksState();

     

     

    ..........

     

    foreach

     

    (DockState state in CurrentDockStates)

     

    {

       string parentZoneID = state.DockZoneID;

    }
    ....

  5. Adrian
    Adrian avatar
    81 posts
    Member since:
    Aug 2006

    Posted 11 May 2009 Link to this post

    Whats the best way to programatically remove dockzones ? 
  6. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 12 May 2009 Link to this post

    If you want to remove dynamically created RadDockZones, all you need to do is not to recreate them on postback.
    The real problem is when a RadDock is in a RadDockZone which is already "removed". You could handle RadDock.OnClientInitialize event and dock a RadDock to the first zone if its parent zone is no longer on the page,e.g.
      function DockInitialize(dockObj,args) {  
                    //Dock current RadDock to the firstZone  
            if(dockObj.get_dockZoneID() == "")  
            {  
                Telerik.Web.UI.RadDockZonesGlobalArray[0].dock(dockObj);  
            }  
        } 
Back to Top