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

Dynamic Add many Dock

8 Answers 147 Views
Dock
This is a migrated thread and some comments may be shown as answers.
restutw
Top achievements
Rank 1
restutw asked on 20 Feb 2008, 09:08 AM
Hi,

I’m creating docks dynamically and store them in a session.It’s based on your example “Dynamically Created Docks”.

I add many docks(more than 5) when I ckick button Add-Dock. But I only see 1 dock states in RadDockZone, the others state on the upper left corner of the page. When I drap a dock from the upper left corner of the page to a RadDockZone or some where, the left docks on the upper left corner of the page are disappear. After I refresh the page, I will see the left docks. Is there any thing I need to notice? So I can add many docks one time to the right RadDockZone and the docks will not disappear!!

8 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Feb 2008, 11:44 AM
Hi restutw,

From the provided description it seems to me that most probably you have problems with the script that is registered in the ButtonAddDock_Click handler. This script should have a different key for every new dock that you add out of the total 5 docks that you want to add at once. In case this clue does not help you, please send us your running project so that we can run it on our side and investigate why the problem occurs. To be able to attach files to your thread you need to open a support ticket as demonstrated in the attached instructions.

Sincerely yours,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Priya
Top achievements
Rank 1
answered on 10 Nov 2008, 04:54 AM

Hi,
did u get the solution for ur prbm.I too have the same prbm...
I gave unique id to script in each loop as

ScriptManager.RegisterStartupScript(dock,

Me.GetType(), "AddDock" + dock.ClientID, String.Format("function _addDock() {{Sys.Application.remove_load(_addDock);$find('{1}').dock($find('{0}'));$find('{0}').doPostBack('DockPositionChanged');}};Sys.Application.add_load(_addDock);", dock.ClientID, RadDockZone1.ClientID), True)
But Still the same prbm exist..only last dock is coming correctly inside the raddock eventhgh, the last dock still does not follow the style of dockzone..all other docks are created at the left corner of the page,one over the other..

Plz help me....
Thanks

 

0
Petio Petkov
Telerik team
answered on 10 Nov 2008, 09:57 AM
Hi Priya,

You should invoke "$find('{0}').doPostBack('DockPositionChanged'')" only for the latest object.
Please find attached an example, which illustrates how to add more than one RadDocks at once.


Greetings,
Petio Petkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Priya
Top achievements
Rank 1
answered on 02 Dec 2008, 12:01 PM

Sir,
I am creating mutiple docks in page_load..
I am getting an error

The control must be in the control tree of a page.
Parameter name: control

The code is

 

 

<telerik:RadDockLayout runat="server" ID="DkLayoutDocMain" Skin="Office2007" onsavedocklayout="DkLayoutDocMain_SaveDockLayout"   
   
 
   
 
 
 
   
   
 
   
 
 
 
onloaddocklayout="DkLayoutDocMain_LoadDockLayout" StoreLayoutInViewState="false" EnableViewState="false">   
   
 
   
 
 
 
   
   
 
   
 
 
 
<telerik:raddockzone runat="server" id="RadDockZone1" Style="float:left;margin-right:10px;border-width:0px" Orientation="Horizontal" Skin="Office2007" Width="100%">   
   
 
   
 
 
 
   
   
 
   
 
   
 
 
 
</telerik:raddockzone> 
 
   
 
   
 
Protected Sub Page_Load  
 
   
 
scriptdock =   
 
"function _addDock() {{Sys.Application.remove_load(_addDock);"   
   
 
   
 
 
 
   
   
 
for i=0 to 2  
    scriptdockscriptdock = scriptdock +   
 
 
 
"}};Sys.Application.add_load(_addDock);"   
   
 
    Dim  
 
dock As RadDock = CreateDock(i)   
   
 
    RadDockZone1.Controls.Add(dock)  
 
    scriptdockscriptdock = scriptdock +   
 
 
 
String.Format("$find('{1}').dock($find('{0}'));", dock.ClientID, RadDockZone1.ClientID)   
   
 
    latestDock = dock 
 
 
 
   
 
 
 
   
   
 
next  
scriptdockscriptdock = scriptdock + "}};Sys.Application.add_load(_addDock);"   
   
 
   
 
 
 
    
   
 
UI.ScriptManager.RegisterStartupScript(latestDock,   
 
 
 
Me.GetType(), "AddDock", scriptdock, True)  
 
 
 
 
 

 

 

 

 

 

plz help me..

 

 

 

 

 

 

 

 

 

0
Vyrban
Top achievements
Rank 1
answered on 02 Dec 2008, 02:14 PM
Hey Priya,

I tried to google your error and can't even find it !!!! So by the logic, this error must be some kind of skipping something trivial in the code. Do you set IDs of the controls ??

Vyrban
0
Priya
Top achievements
Rank 1
answered on 03 Dec 2008, 04:09 AM

hi,

The create dock fn is lik this

Protected Function CreateDock(ByVal i as integer) As RadDock  
Dim strScript As String  
Dim dock As New RadDock()  
dock.UniqueName = Guid.NewGuid().ToString()  
dock.ID = String.Format("RadDock{0}", dock.UniqueName)  
dock.Text =i.tostring()  
dock.Commands.Add(New DockCloseCommand())  
dock.Commands.Add(New DockExpandCollapseCommand())  
dock.EnableDrag = True 
dock.DockMode = DockMode.Default  
dock.Style("width") = "80%"  
strScript = "<script language=javascript>" 
strScript += "function SetTheDockHandle(dock, args){ var dockobj = $find('<%= dock.ClientID %>');dock.set_handle(dockobj.get_element());}"  
strScript += "<"  
strScript += "/script>"  
Page.RegisterStartupScript("MSGE", strScript)  
Return dock  
End Function  
 


I didnt used any updatepanel.
How can i create dock_command without using updatepanel..
thanks

0
Petko
Telerik team
answered on 04 Dec 2008, 07:09 AM
Hello Priya,

The provided information is insufficient, and we cannot reproduce the problem. Please, send us simple running project, where we can observe this issue. Once we receive it, we will do our best to help you. About "dock_command" creation - do you mean how to add dynamically DockCommand handler?

Sincerely yours,
Petko
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Ulises
Top achievements
Rank 1
answered on 06 Dec 2008, 08:01 PM

Hi priya, restutw.  I found a simple solution for the problem with the raddock-dissapear after you move to another radzone or whatever place in radlayout.

 

I only added a variable to the function _addDock and i added the same variable in the function where exists the string _addDock.

Check my code. Its easy.  the trick is "function _addDock" + i.ToString()". "i" variable  is a unique key for each loop ( the classic for(int i = 0; bla bla bla code)

This problem is generated because when register the script, in the client side script we have two or more functions with the "_AddDock" name and we need to give a unique name fore each RadDock in the loop.

Remember the DockPositionChanged trick for the last raddock in the loop (i put the code from the forums, 10ks) and solve it.

If anybody have a question. Reply.  CIAO

// inside in your loop

if

 

(i == objArreglo.Count)

 

{

 

ScriptManager.RegisterStartupScript(

 

UpdatePanel1,

 

typeof(RadDock),

 

 

"AddDock" + i.ToString(),

 

 

string.Format("function _addDock" + i.ToString() + "() {{ Sys.Application.remove_load(_addDock" + i.ToString() + "); $find('{1}').dock($find('{0}')); $find('{0}').doPostBack('DockPositionChanged');}}; Sys.Application.add_load(_addDock" + i.ToString() + ");", dock.ClientID, rdTelCompa1.ClientID), true);

 

}

 

else

 

{

 

ScriptManager.RegisterStartupScript(

 

UpdatePanel1,

 

typeof(RadDock),

 

 

"AddDock" + i.ToString(),

 

 

string.Format("function _addDock" + i.ToString() + "() {{ Sys.Application.remove_load(_addDock" + i.ToString() + "); $find('{1}').dock($find('{0}')); }}; Sys.Application.add_load(_addDock" + i.ToString() + ");", dock.ClientID, rdTelCompa1.ClientID), true);

 

}

Tags
Dock
Asked by
restutw
Top achievements
Rank 1
Answers by
Petya
Telerik team
Priya
Top achievements
Rank 1
Petio Petkov
Telerik team
Vyrban
Top achievements
Rank 1
Petko
Telerik team
Ulises
Top achievements
Rank 1
Share this question
or