16 Answers, 1 is accepted
http://www.telerik.com/demos/aspnet/prometheus/Dock/Examples/MyPortal/DefaultCS.aspx
RadDocks are created dynamically. When the RadDock is moved its state is saved in the session .
Thanks,
XmlSerializer ser = new XmlSerializer(typeof(List<DockState>));
System.IO.StringWriter writer = new System.IO.StringWriter();
ser.Serialize(writer, this.RadDockLayout1.GetRegisteredDocksState());
//
// Save to database
//
SaveDockLayout(writer.toString());
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Dock/Examples/LoadSaveLayout/DefaultCS.aspx
However, once you implement the savestate functionality with the XmlSerializer, you can post it:)
http://www.telerik.com/community/forums/thread/b311D-maehh.aspx
I found it a useful source of information on persisting dockState to a database. It contains a sample app put together by one of the Telerik guys demonstrating what needs to be done.
The best way to add RadDocks via AJAX is shown in the MyPortal example. The VB version isvailable here:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Dock/Examples/MyPortal/DefaultVB.aspx
Also you can use telerik converter to convert a code from C# to VB here:
http://converter.telerik.com/
Please, find below a simple VB code which demonstrates how to achieve saving/loading dock's state from DataBase:
Protected Sub RadDockLayout1_SaveDockLayout(ByVal sender As Object, ByVal e As Telerik.Web.UI.DockLayoutEventArgs) |
Dim dockState As String |
Dim serializer As New Script.Serialization.JavaScriptSerializer() |
Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState() |
Dim serializedList As New StringBuilder() |
Dim i As Integer = 0 |
While i < stateList.Count |
serializedList.Append(serializer.Serialize(stateList(i))) |
serializedList.Append("|") |
i += 1 |
End While |
dockState = serializedList.ToString() |
'Save the dockState string into DB |
End Sub |
protected Sub RadDockLayout1_LoadDockLayout(ByVal sender As Object, ByVal e As Telerik.Web.UI.DockLayoutEventArgs) |
Dim serializer As New Script.Serialization.JavaScriptSerializer() |
'Get saved state string from the database - set it to dockState variable for example |
Dim currentDockStates As String() = dockState.Split("|") |
For Each stringState As String In currentDockStates |
If stringState <> String.Empty Then |
Dim state As DockState = serializer.Deserialize(Of DockState)(stringState) |
e.Positions(state.UniqueName) = state.DockZoneID |
e.Indices(state.UniqueName) = state.Index |
End If |
Next |
End Sub |
If you want to save the positions of the docks whenever you want (upon a button click event for example) instead of at savedocklayout you simply need to store the info about the added docks in session/cookie/database when the button is clicked. You need to simply move the code from the savedocklayout event handler to your button's event handler. For your convenience I have prepared an example demonstrating how to save the dock's state at a button click. There are some comments which can help you better understand the provided implementation. You will need to modify it so that it is answers the requirements of your scenario. Please, review the attached example and let us know if you need further assistance.
Kind regards,
Sophy
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Is there a way to also save and load a raddock's collapse or close status also?
hi,
Try this code , hope this helps
protected void RadDockLayout1_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)
{
STDockRoot dockRootObj = new STDockRoot();
STDock dockobj = new STDock();
dockobj = dockRootObj.GetMailById(1);
if (!Object.Equals(dockobj, null))
{
string serializedPositionsAndIndices = dockobj.Postion;
if (!string.IsNullOrEmpty(serializedPositionsAndIndices))
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
string[] positionsAndIndices = serializer.Deserialize<string[]>(serializedPositionsAndIndices);
e.Positions = serializer.Deserialize<Dictionary<string, string>>(positionsAndIndices[0]);
e.Indices = serializer.Deserialize<Dictionary<string, int>>(positionsAndIndices[1]);
}
}
}
protected void RadDockLayout1_SaveDockLayout(object sender, DockLayoutEventArgs e)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
string serializedPositions = serializer.Serialize(e.Positions);
string serializedIndices = serializer.Serialize(e.Indices);
STDockRoot dockRootObj = new STDockRoot();
dockRootObj.InsertDockPostion(1,serializer.Serialize(new string[] { serializedPositions, serializedIndices }));
}
use ur own type of connection and try
regards
Navin
Currently, there are some complex scenarios with RadAjax in which the proper functioning of the RadDock for ASP.NET is disturbed. We are working on improving the interoperability between RadAjax and RadDock for ASP.NET AJAX but for the time being we recommend using UpdatePanels.
All the best,
Sophy
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
On my side, I'm unable to make it works with Telerik Ajax
The following article from our Code Library shows how to have a portal application that uses RadAjaxManager and saves the state of the docks in a DB: http://www.telerik.com/community/code-library/aspnet-ajax/docking/save-dockstate-in-database-using-radajaxmanager.aspx.
Best wishes,
Pero
the Telerik team