I took the sample code on the website and modified it to add an array of items. Basically I have an array of strings and for each stirng in that array add a new RadDock control to the RadDockZone and have the RadDock's text property = the string value in the array.
From the originial code I have only modified the code below.
This sounds simple enough but for some reason only the first item in the array is being added to the RadDockZone.
So I'm guessing it has to do something with the order of precedence?
From the originial code I have only modified the code below.
This sounds simple enough but for some reason only the first item in the array is being added to the RadDockZone.
So I'm guessing it has to do something with the order of precedence?
private void AddDocks(string text) |
{ |
RadDock dock = CreateRadDock(text); |
//In order to optimize the execution speed we are adding the dock to a |
// hidden update panel and then register a script which will move it |
// to RadDockZone1 after the AJAX request completes. If you want to |
// dock the control in other zone, modify the script according your needs. |
UpdatePanel1.ContentTemplateContainer.Controls.Add(dock); |
ScriptManager.RegisterStartupScript( |
dock, |
this.GetType(), |
"AddDock", |
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); |
//Right now the RadDock control is not docked. When we try to save its state |
// later, the DockZoneID will be empty. To workaround this problem we will |
// set the AutoPostBack property of the RadDock control to true and will |
// attach an AsyncPostBackTrigger for the DockPositionChanged client-side |
// event. This will initiate second AJAX request in order to save the state |
// AFTER the dock was docked in RadDockZone1. |
CreateSaveStateTrigger(dock); |
} |
protected void ButtonAddDock_Click(object sender, EventArgs e) |
{ |
List<string> array = new List<string>(); |
array.Add("test1"); |
array.Add("test2"); |
array.Add("test3"); |
for (int i = 0; i < array.Count; i++) |
{ |
AddDocks(array[i].ToString()); |
} |
} |
private RadDock CreateRadDock(string text) |
{ |
int docksCount = CurrentDockStates.Count; |
RadDock dock = new RadDock(); |
dock.UniqueName = Guid.NewGuid().ToString(); |
dock.ID = string.Format("RadDock{0}", dock.UniqueName); |
dock.Title = "Dock"; |
dock.Text = text; |
dock.Width = Unit.Pixel(300); |
dock.Commands.Add(new DockCloseCommand()); |
dock.Commands.Add(new DockExpandCollapseCommand()); |
dock.Command += new DockCommandEventHandler(dock_Command); |
return dock; |
} |