Hi Pero,
So, this is working great! I have a question, though. Is there an elegant way of obtaining the height/width of a DockZone when I leave these values unset? I am trying to resize a control located inside of a RadDock. I would like it to be the same size as the RadDock. Unfortunately, the height and width properties are empty. Same with the RadDockZone and the RadPane parent controls.
I wrote some code previously to allow me to persist height/width for when the client drags slider bars around (thus resizing the pane). It's ugly, but here it is:
protected void Page_Load(object sender, EventArgs e)
{
RegisterCallBackReference();
}
private void RegisterCallBackReference()
{
String callBack = Page.ClientScript.GetCallbackEventReference(this, "arg", "CallbackOnSucceeded", "context", "CallbackOnFailed", true);
String clientFunction = "function CallSetDimensions(arg, context){ " + callBack + "; }";
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Call To Server", clientFunction, true);
}
#region ICallbackEventHandler Members
String returnValue;
string ICallbackEventHandler.GetCallbackResult()
{
return returnValue;
}
void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
bool result = SetDimensions(eventArgument);
if (result)
{
returnValue = "Success.";
}
else
{
returnValue = "Failure.";
}
}
#endregion
private bool SetDimensions(string args)
{
bool saveSuccessful = false;
string[] paneIDandHeightandWidth = args.Split(',');
string paneID = paneIDandHeightandWidth[0];
int paneHeight = 0;
int.TryParse(paneIDandHeightandWidth[1], out paneHeight);
int paneWidth = 0;
int.TryParse(paneIDandHeightandWidth[2], out paneWidth);
RadPane pane = Utilities.FindControlRecursive(Page, paneID) as RadPane;
if (!object.Equals(pane, null))
{
saveSuccessful = true;
RadPaneSetting paneSetting = RadPaneSetting.GetSettings(pane);
pane.Height = new Unit(paneHeight, UnitType.Pixel);
pane.Width = new Unit(paneWidth, UnitType.Pixel);
controlSave.SavePane(pane);
}
return saveSuccessful;
}
I spoke with Dobormir
here and he alluded that this was an acceptable means of doing such a thing. Essentially, whenever my pane gets resized by the RadSplitter, I capture the height/width of the pane and pass it back to the server so that I am able to save its height/width when the dynamic controls need to be restored.
I would be OK (but not SUPER happy) using this same functionality to achieve my desired results. Unfortunately, I am not convinced this is possible. First, RadPane does not have an OnClientLoad event. I captured the RadSplitter's OnClientLoad event, parsed out it's child pane's height/width and stored those, but the event only fires on page refreshes -- not whenever the page reinitializes.
Currently, I have my RadDock's control resizing to a proper height/width when it is first created because dropping the RadDock onto the page seems to fire PaneResize event (also sketchy, but working with it for now..). But, if I grab the RadDock and then drop it back onto the same RadDockZone the page reinits without any dimensions changing so the height/width is back to being perceived as empty.
Any ideas on this one?
Thanks for your time.