saving and loading dock state with database

17 posts, 0 answers
  1. Amey
    Amey avatar
    16 posts
    Member since:
    Feb 2008

    Posted 04 Mar 2008 Link to this post

    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?
  2. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 10 Mar 2008 Link to this post

    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 .
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Gabriel Beauchamp
    Gabriel Beauchamp avatar
    41 posts
    Member since:
    Jan 2008

    Posted 10 Mar 2008 Link to this post

    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,
  5. Gabriel Beauchamp
    Gabriel Beauchamp avatar
    41 posts
    Member since:
    Jan 2008

    Posted 10 Mar 2008 Link to this post

    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());
  6. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 18 Mar 2008 Link to this post

     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:)
  7. AK
    AK avatar
    30 posts
    Member since:
    Jun 2012

    Posted 30 Jun 2008 Link to this post

    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.
  8. brad
    brad avatar
    11 posts
    Member since:
    Apr 2008

    Posted 01 Jul 2008 Link to this post

    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.
  9. AK
    AK avatar
    30 posts
    Member since:
    Jun 2012

    Posted 01 Jul 2008 Link to this post

    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.
  10. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 01 Jul 2008 Link to this post

    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/

  11. AK
    AK avatar
    30 posts
    Member since:
    Jun 2012

    Posted 02 Jul 2008 Link to this post

    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.
  12. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 03 Jul 2008 Link to this post

    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
  13. AK
    AK avatar
    30 posts
    Member since:
    Jun 2012

    Posted 03 Jul 2008 Link to this post

    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?
  14. Navin
    Navin avatar
    10 posts
    Member since:
    Jun 2008

    Posted 05 Jul 2008 Link to this post



    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

  15. Matt
    Matt avatar
    5 posts
    Member since:
    Sep 2007

    Posted 06 Jul 2008 Link to this post

    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.
  16. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 07 Jul 2008 Link to this post

    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
  17. arnaud
    arnaud avatar
    104 posts
    Member since:
    Jul 2008

    Posted 04 Feb 2011 Link to this post

    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
  18. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 07 Feb 2011 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017