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

Add Dock dynamically to bottom of zone

6 Answers 95 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Danny Scheelings
Top achievements
Rank 1
Danny Scheelings asked on 31 Jul 2009, 01:21 PM
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

6 Answers, 1 is accepted

Sort by
0
Mr. Plinko
Top achievements
Rank 1
answered on 31 Jul 2009, 03:24 PM
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.
0
Danny Scheelings
Top achievements
Rank 1
answered on 31 Jul 2009, 06:32 PM
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
0
Pero
Telerik team
answered on 03 Aug 2009, 02:58 PM
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.
0
Danny Scheelings
Top achievements
Rank 1
answered on 04 Aug 2009, 10:12 AM
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
0
Pero
Telerik team
answered on 06 Aug 2009, 08:54 AM
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.
0
Pete
Top achievements
Rank 1
answered on 06 Jul 2011, 06:16 AM
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()...
Tags
Dock
Asked by
Danny Scheelings
Top achievements
Rank 1
Answers by
Mr. Plinko
Top achievements
Rank 1
Danny Scheelings
Top achievements
Rank 1
Pero
Telerik team
Pete
Top achievements
Rank 1
Share this question
or