I am currently adding new RadDocks using "RadDock.Dock(RadDockZone)".
Would I be able to use something like "rdlDockLayout.RegisteredDocks.Reverse()" or "rdlDockLayout.RegisteredDocks.OrderByDescending(...)"?
I would prefer to accomplish this using VB.NET.
11 Answers, 1 is accepted
dock.Index = 0; zone.Docks.Add(dock); |
In the documentation for get_index, Telerik says, "To change the docking position of the control, use the dock method of the parent docking zone". I don't see any dock method belonging to the RadDockZone, but only to the RadDock, which doesn't allow one to specify the position to dock it, just the RadDockZone to dock it within.
Would you happen to have any other suggestions? Thanks for your time.
protected void rdlFramework_LoadDockLayout(object sender, DockLayoutEventArgs e) |
{ |
//Populate the event args with the state information. The RadDockLayout control |
//will automatically move the docks according that information. |
foreach (Telerik.Web.UI.DockState state in CurrentDockStates) |
{ |
e.Positions[state.UniqueName] = state.DockZoneID; |
e.Indices[state.UniqueName] = state.Index; |
} |
} |
- User clicks RadDock to add
- RadDock is added to RadDockZone via server-side code
- RadDockLayout is saved back to the database
I would need to change the index somewhere between steps 1 and 2, on the client-side. I would also presumably have to increment the indices of the other RadDocks in the RadDockZone to move them down one position.
I am actually already using the same code as you in my DockLayout.LoadDockLayout event handler.
Do you have any other suggestions? I appreciate your time and willingness to help out!
function DockRadDock1ToRightZone() |
{ |
var leftZone = $find('<%= RadDockZone2.ClientID%>'); |
var dock = $find('<%= RadDock1.ClientID%>'); |
if (dock && leftZone && dock.get_parent().get_id() != "RadDockZone2") |
{ |
leftZone.dock(dock, 0); |
} |
} |
I believe that I have come up with a 99% solution. When dynamically adding a new RadDock upon the user's request, I associate the RadDock's "OnClientInitialize" with a custom JavaScript function that simply docks it to its parent RadDockZone (because at the point of OnClientInitialize, the RadDock already belongs to a RadDockZone) in position 0.
RadDock.OnClientInitialize = "DockAtTop" |
function DockAtTop(sender, eventArgs) |
{ |
sender.get_parent().dock(sender, 0); |
__doPostBack('<%=RadDockLayoutUpdatePanel.ClientID%>', ''); |
} |
As you can see, I also have to explicitly force a PostBack in order for each RadDock's new index to be saved to my database.
The reason I call this a 99% solution is that, in some cases, when adding a RadDock that contains a FusionCharts Map as well as a RadSlider, the "__doPostBack()" line raises a 'parentNode' is null or not an object error. This error doesn't keep anything from functioning correctly, and I've tried providing different objects as __doPostBack()'s first parameter to no avail.
If anybody has any thoughts on this, please let me know!
By the way, Gido's suggestion as well as Telerik's documentation (bottom example at http://www.telerik.com/help/aspnet-ajax/dock_client-side_basics.html) helped me arrive at this solution.
Another way of placing the RadDock at the desired index in the RadDockZone through the DockZone.dock(dock, index) client-side method is to register a client-script from the server (instead of using the OnClientInitialize event). This is the code that registers the script:
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, DropDownZone.SelectedValue, dockPosition),
true
);
If you need to perform a postback to save the dockstate please follow Gido's suggestion.
For your convenience, I have attached a sample project (a modification of MyPortal demo) that follows this logic.
Regards,
Pero
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Thank you for the suggestion. However, even after registering the Javascript server-side, I am still getting the 'parentNode' is null or not an object error. I appreciate you time in addressing this issue. Please let me know if you have any further thoughts as to prevent this error from happening. I would be happy to open up a ticket and send you a sample of my code if you would like.
Thanks again.
~Ryan
I don't know what might be causing the issue when "__doPostBack()" is called, but if you provide a sample I can try to debug the problem and will do my best to find a solution.
I am looking forward to receiving your project.
All the best,
Pero
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.