This is a migrated thread and some comments may be shown as answers.

saving and loading dock state with database

16 Answers 361 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Amey
Top achievements
Rank 1
Amey asked on 05 Mar 2008, 05:26 AM
I would like to save the dock state when user moves docks from one place to the other. I would like to load this new dock state when user logs into my website next time. The dock state should be saved in the database when user click on save state button and it should be loaded from the database when user logs on next time to my website. I don't want the HttpCookie for saving the dock state configuration. How can I achive this?

16 Answers, 1 is accepted

Sort by
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 10 Mar 2008, 08:58 AM
You can take a look at the following example:
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 .
0
Gabriel Beauchamp
Top achievements
Rank 2
answered on 10 Mar 2008, 03:13 PM
In that example, it saves a List Collection Object in the session variable. If you want to store it in a database, you'll need to serialize it into xml or something? No?

Thanks,
0
Gabriel Beauchamp
Top achievements
Rank 2
answered on 10 Mar 2008, 03:56 PM
What about something like this?

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());
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 18 Mar 2008, 03:30 PM
 There is a online example where a JavascriptSerializer is used:
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:)
0
AK
Top achievements
Rank 1
answered on 30 Jun 2008, 09:37 PM
I can't get save/load state to work at all with database. It was quite simple with dock classis. Can anyone provide code that works with save/load from database? Preferably, the save is initated with button save. VB.net code please.
0
brad
Top achievements
Rank 1
answered on 01 Jul 2008, 05:53 AM
Have a look at the following thread:
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.
0
AK
Top achievements
Rank 1
answered on 01 Jul 2008, 03:38 PM
I've seen that thread. Too complex for me to work through. I just need some simple code for saving and loading state. I can deal with db operations. I just need working code to capture and load state.
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 01 Jul 2008, 04:39 PM
Do you create RadDocks dynamically?
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/

0
AK
Top achievements
Rank 1
answered on 02 Jul 2008, 02:18 PM
Thanks for the leads. I think I saw most of those. No, the Docks are created at design time so it should be a bit more straight forward but I just can't seem to get it working from any of the examples.
0
Sophy
Telerik team
answered on 03 Jul 2008, 06:53 AM
Hi Andrew,

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 ObjectByVal 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 ObjectByVal 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
0
AK
Top achievements
Rank 1
answered on 03 Jul 2008, 08:20 PM
Thanks Sophy. That helped a lot and I have it working well to save and load via database.

Is there a way to also save and load a raddock's collapse or close status also?
0
Navin
Top achievements
Rank 1
answered on 05 Jul 2008, 07:58 AM


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

0
Matt
Top achievements
Rank 2
answered on 06 Jul 2008, 05:57 AM
Why do so many examples from Telerik use the Microsoft UpdatePanel instead of the RadAjaxPanel?  I'd like to just use one or the other but I do like the Telerik version a little better display-wise than the MS version so I'd like to see more of the examples and demos using Telerik versions where available as it makes me question why I am using their components in the first place if they aren't.
0
Sophy
Telerik team
answered on 07 Jul 2008, 09:55 AM
Hi Matt,

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
0
arnaud
Top achievements
Rank 1
answered on 04 Feb 2011, 06:12 PM
As far as I can see in your online demo, you are still using classic update panels 3 years later.
On my side, I'm unable to make it works with Telerik Ajax
0
Pero
Telerik team
answered on 07 Feb 2011, 09:58 AM
Hello Arnaud,

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
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Dock
Asked by
Amey
Top achievements
Rank 1
Answers by
Obi-Wan Kenobi
Top achievements
Rank 1
Gabriel Beauchamp
Top achievements
Rank 2
AK
Top achievements
Rank 1
brad
Top achievements
Rank 1
Sophy
Telerik team
Navin
Top achievements
Rank 1
Matt
Top achievements
Rank 2
arnaud
Top achievements
Rank 1
Pero
Telerik team
Share this question
or