Add Dock dynamically to bottom of zone

7 posts, 0 answers
  1. Danny Scheelings
    Danny Scheelings avatar
    69 posts
    Member since:
    Jan 2006

    Posted 31 Jul 2009 Link to this post

    Hi,

    I'm using the example from http://demos.telerik.com/aspnet-ajax/dock/examples/dynamicdocks/defaultcs.aspx to dynamically add Docks to a DockZone. In this example every new Dock is added to the top position of all Docks within the Zone.

    Is it possible to add the new Docks to the bottom position of all Docks within the Zone?

    Thanks,
    Danny
  2. Mr. Plinko
    Mr. Plinko avatar
    56 posts
    Member since:
    Jul 2009

    Posted 31 Jul 2009 Link to this post

    Are you asking if there is a way to create a dock dynamically at the bottom of a dock zone (visually) or if there is a way to create a dock to be displayed under current docks?

    If it is the latter, Obi-Wan Kenobi addresses this here saying that in the C# code,

    RadDocZone1.Controls.Add(dock); is equal to RadDocZone1.Controls.AddAt(RadDocZone1.Controls.Count, dock);

    Meaning that if you AddAt and then count the number of docks, you can place the new dock at the end.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Danny Scheelings
    Danny Scheelings avatar
    69 posts
    Member since:
    Jan 2006

    Posted 31 Jul 2009 Link to this post

    Thanks for your reply.

    I already tried using RadDocZone1.Controls.AddAt(RadDocZone1.Controls.Count, dock);  in stead of RadDocZone1.Controls.Add(dock);  but the Docks are always added at the top of the zone. It looks like that the index parameter used in the AddAt method does not do anything to the order of the Docks in the zone.

    Do you have an other solution?

    Thanks,
    Danny
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 03 Aug 2009 Link to this post

    Hi Danny,

    When a RadDock is added dynamically to a zone it is docked on the first position (index zero), by default. In order to add the dock to the last position (i.e. the RadDock to be docked on the last position) we simply use client-script (dynamically added from the server) that moves the RadDock to the last position (or to any desired position). The source code which registers the JavaScript function used to move the dock to the last place in the zone, is pasted below. It finds the client object of the current RadDockZone,  and then calls the client method dock (zone.dock(RadDockToBeMoved, DockingPosition)).

    //move dock to the last place in the RadDockZone 
    ScriptManager.RegisterStartupScript(this
        this.GetType(), 
        "MoveDock"
    string.Format(@"function _moveDock() {{
                Sys.Application.remove_load(_moveDock);
                $find('{1}').dock($find('{0}'),{2});
                }};
                Sys.Application.add_load(_moveDock);", dock.ClientID, RadDockZone1.ID, RadDockZone1.Docks.Count), true);


    The above source code should be placed in the event handler method for the OnClick event of the ButtonAddDock Button, just below the source code that adds the dock to the zone.

    Additionally I am attaching a project - modified "my portal" example - that adds the docks at the last position in the zone. 


    Kind regards,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Danny Scheelings
    Danny Scheelings avatar
    69 posts
    Member since:
    Jan 2006

    Posted 04 Aug 2009 Link to this post

    Hi Pero,

    Thanks for your detailed reply. I think I can use this for my solution.
    Just to be sure: there is no way to do this completely at the server side?

    Thanks,
    Danny
  7. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 06 Aug 2009 Link to this post

    Hi Danny,

    For the time being this is the only way (on the client-side) to add a RadDock at the last position in the zone. It cannot be done on the server-side.

    Best wishes,
    Pero
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Pete
    Pete avatar
    14 posts
    Member since:
    May 2009

    Posted 06 Jul 2011 Link to this post

    I just tried using this solution and it wasn't working for me. After trial and error I figured out a few things, so for future reference to anyone who is looking to use this solution:
    1. RadDockZone1.ID should be RadDockZone1.ClientID
    2. If you're using an update panel then for the Control parameter of the RegisterStartupScript method of the RegisterStartupScript don't use this, use the UpdatePanel instead e.g. ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType()...
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017