I have the following RadDock on the my page and noticed that when I reorder docs the first time this new order isnt saved. But second time thru if i preform a reorder everything sticks like its supposed to.
ASCX code:
Class code:
Again, the problem is that initially the page loads the dynamically created RadDocs in thier correct order. I move the bottom most doc to the be the top most doc and the page posts back. Ok so while the page posts back, the order doenst change and mr bottom doc remains on the bottom. BUT!!! if i reorder AFTER the first post back, the docs retain thier placement.
J
ASCX code:
<telerik:RadDockLayout runat="server" ID="RadDockLayout1" |
OnLoadDockLayout="RadDockLayout1_LoadDockLayout" |
OnSaveDockLayout="RadDockLayout1_SaveDockLayout" |
StoreLayoutInViewState=true |
> |
<div id="div_rdZoneCurrentCycle"> |
<telerik:RadDockZone runat="server" ID="RadDockZone_ExistingPriorities" |
BorderStyle="None" |
MinHeight="30px" width="100%" |
> |
</telerik:RadDockZone> |
</div> |
</telerik:RadDockLayout> |
Class code:
public partial class SSPPrioritizePriorities : System.Web.UI.UserControl |
{ |
private List<DockState> CurrentDockStates |
{ |
get |
{ |
// Store the info about the added docks in the session. |
List<DockState> _currentDockStates = (List<DockState>)Session["CurrentDockStatesDynamicDocks"]; |
if (Object.Equals(_currentDockStates, null)) |
{ |
_currentDockStates = new List<DockState>(); |
Session["CurrentDockStatesDynamicDocks"] = _currentDockStates; |
} |
return _currentDockStates; |
} |
set |
{ |
Session["CurrentDockStatesDynamicDocks"] = value; |
} |
} |
#endregion |
const string TitleBarText = "TitleText"; |
const string CurrentRank = "CurRankText"; |
const string PreviousRank = "PreRankText"; |
#endregion |
#region " Page Load Events " |
protected void Page_Load(object sender,EventArgs e) |
{ |
} |
protected override void OnInit(EventArgs e) |
{ |
base.OnInit(e); |
if (!Page.IsPostBack) |
{ |
using (ObjectsContext context = new ObjectsContext()) |
{ |
MyManager manager = new MyManager(context); |
CurrentCyclePriorities = manager.something.Cycle(); |
CurrentCycleSSP = manager.somehingelse.GetCurrent(this._SSPK); |
PreviousCycleSSP = manager.somehingelse.GetPrevious(this._SSPK); |
LoadPriorities(); |
} |
} |
else |
{ |
for (int i = 0; i < CurrentDockStates.Count; i++) |
{ |
RadDock dock = CreateRadDockFromState(CurrentDockStates[i]); |
RadDockLayout1.Controls.Add(dock); |
CreateSaveStateTrigger(dock); |
} |
} |
SetRadDockOrder(); |
} |
#endregion |
#region " Priorities Load Events " |
protected void LoadPriorities() |
{ |
CreateRadDock(sspPrevious.Priority, true, true, false, |
} |
#endregion |
#region " Dock Events " |
#region " Create " |
private void CreateRadDock(BusinessObjects.Priority apriority, Boolean BottomDock, Boolean Closed, Boolean New, int previousRanking, int? CurrentRanking) |
{ |
try |
{ |
// Create the Rad Dock and set properties |
RadDock dock = new RadDock(); |
dock.DockMode = DockMode.Docked; |
dock.DockHandle = DockHandle.TitleBar; |
dock.Collapsed = true; |
dock.Width = Unit.Percentage(96); |
dock.Skin = "MySkin"; |
dock.EnableEmbeddedSkins = false; |
dock.EnableRoundedCorners = true; |
dock.EnableAnimation = true; |
dock.Font.Name = "Arial"; |
int intIndex = dock.Index; |
dock.AutoPostBack = true; |
dock.CommandsAutoPostBack = true; |
// Create the TitleBar and add to Rad Dock |
TitleBarTemplate2 tbt = new TitleBarTemplate2(); |
tbt.GenerateTitleBar(dock.TitlebarContainer, 5); |
dock.TitlebarTemplate = tbt; |
// Add Rad Dock Title information |
dock.UniqueName = apriority.PK.ToString(); |
dock.ID = string.Format("rd{0}", dock.UniqueName); |
dock.Title = "<span style=\"font-size:14px;\"><b>" + apriority.PK.ToString() + "</b></span> "; |
((Label)dock.TitlebarContainer.Controls[0].FindControl(TitleBarText)).Text = dock.Title; |
// Add Rad Dock Previous Rank information |
if (!New) |
{ |
String preRanking = "<span style=\"font-size:14px;\"><b>(" + previousRanking.ToString() + ")</b></span>"; |
((Label)dock.TitlebarContainer.Controls[0].FindControl(PreviousRank)).Text = preRanking; |
} |
// Set Rad Dock Events and Triggers |
if (BottomDock) |
dock.OnClientDragStart = "OnClientDragStart"; |
CreateSaveStateTrigger(dock); |
RadDockZone_ExistingPriorities.Controls.Add(dock); |
} |
catch (Exception ex) |
{ |
string s = ex.StackTrace; |
} |
} |
#endregion |
#region " Order " |
private void SetRadDockOrder() |
{ |
foreach (RadDock dock in RadDockZone_ExistingPriorities.Docks) |
{ |
((Label)dock.TitlebarContainer.Controls[0].FindControl(CurrentRank)).Text = ""; |
int newRank = dock.Index + 1; |
String newRanking = "<span style=\"font-size:14px;\"><b>" + newRank.ToString() + ".</b></span>"; |
((Label)dock.TitlebarContainer.Controls[0].FindControl(CurrentRank)).Text = newRanking; |
} |
} |
#endregion |
#region " States " |
private RadDock CreateRadDockFromState(DockState state) |
{ |
RadDock dock = new RadDock(); |
//// Create the TitleBar and add to Rad Dock |
TitleBarTemplate2 tbt = new TitleBarTemplate2(); |
tbt.GenerateTitleBar(dock.TitlebarContainer, 5); |
dock.TitlebarTemplate = tbt; |
//// Add Rad Dock Title information |
dock.UniqueName = state.UniqueName; |
//dock.Index = state.Index; |
dock.Title = "<span style=\"font-size:14px;\"><b>" + dock.UniqueName + "</b></span> "; |
((Label)dock.TitlebarContainer.Controls[0].FindControl(TitleBarText)).Text = state.Title; |
return dock; |
} |
private void CreateSaveStateTrigger(RadDock dock) |
{ |
// Ensure that the RadDock control will initiate postback when its position changes on the client or any of the commands is clicked. |
// Using the trigger we will "ajaxify" that postback. |
dock.AutoPostBack = true; |
dock.CommandsAutoPostBack = true; |
} |
protected void RadDockLayout1_LoadDockLayout(object sender, DockLayoutEventArgs e) |
{ |
foreach (DockState state in CurrentDockStates) |
{ |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
} |
} |
protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e) |
{ |
CurrentDockStates = new List<DockState>(); |
foreach (DockState ds in RadDockLayout1.GetRegisteredDocksState()) |
{ |
CurrentDockStates.Add(ds); |
} |
} |
#endregion |
#endregion |
} |
Again, the problem is that initially the page loads the dynamically created RadDocs in thier correct order. I move the bottom most doc to the be the top most doc and the page posts back. Ok so while the page posts back, the order doenst change and mr bottom doc remains on the bottom. BUT!!! if i reorder AFTER the first post back, the docs retain thier placement.
J