radDock Close and Minimize Problem when save

16 posts, 0 answers
  1. Mohammad
    Mohammad avatar
    13 posts
    Member since:
    Sep 2008

    Posted 21 Mar 2009 Link to this post

    Dear All,

    when save the docks on page after user cusomize position and every thing on cookies using this code,,,


    protected

    void RadDockLayout1_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)

     

    {

    HttpCookie dockState = Page.Request.Cookies.Get(

    "MyApplicationDockStates85216");

     

     

    if (dockState != null)

     

    {

     

    string serializedList = dockState.Value;

     

     

    if (serializedList != null)

     

    {

     

    string[] states = serializedList.Split('|');

     

     

    for (int i = 0; i < states.Length; i++)

     

    {

    DockState state = DockState.Deserialize(states[i]);

    e.Positions[state.UniqueName] = state.DockZoneID;

    e.Indices[state.UniqueName] = state.Index;

    }

    }

    }
    }

    and 

     

    protected

    void RadDockLayout1_SaveDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)

     

    {

    HttpCookie dockState = Page.Response.Cookies.Get(

    "MyApplicationDockStates85216");

     

     

    if (dockState == null)

     

    {

    dockState =

    new HttpCookie("MyApplicationDockStates85216");

     

    Page.Response.Cookies.Add(dockState);

    }

     

    List<DockState> stateList = ((RadDockLayout)sender).GetRegisteredDocksState();

     

     

    StringBuilder serializedList = new StringBuilder();

     

     

    for (int i = 0; i < stateList.Count; i++)

     

    {

    serializedList.Append(stateList[i].ToString());

    serializedList.Append(

    "|");

     

    }

    dockState.Expires =

    DateTime.Today.AddMonths(1);

     

    dockState.Value = serializedList.ToString();

     

    }

    all position saved and every thing well but closed Docks or minimze Docks not saved
    i.e when close dock or minmize dock,,,,after postback the closed/minimzed docks still as first time

    anyone have solution for this problem?

    thanks in advanced

  2. Mohammad
    Mohammad avatar
    13 posts
    Member since:
    Sep 2008

    Posted 22 Mar 2009 Link to this post

    no any answer!!!!!!!!!!!!!!!!!!!!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 23 Mar 2009 Link to this post

    Hello Mohammad,

    Try to invoke  dock.ApplyState(state); in RadDockLayout1_LoadDockLayout handler, e.g.

    void RadDockLayout1_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)
    {
    ............
    {

    DockState state = DockState.Deserialize(states[i]);
    RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName);
    dock.ApplyState(state);
    e.Positions[state.UniqueName] = state.DockZoneID;
    e.Indices[state.UniqueName] = state.Index;
    }
    ......
    }

    Hope this helps.

    All the best,

    Petio Petkov
    the Telerik team


    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  5. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 24 Apr 2009 Link to this post

    I get an error on this "states[i]" What is states?

    Thanks,
    Sam
  6. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 27 Apr 2009 Link to this post

    Any answer on this problem? states[i] isn't defined in your block of code.
  7. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 28 Apr 2009 Link to this post

    Petio,

    Can you explain what states[i] is????? I get a compile error because it's not defined.

    void RadDockLayout1_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)
    {
    ............
    {
    DockState state = DockState.Deserialize(states[i]);
    RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName);
    dock.ApplyState(state);
    e.Positions[state.UniqueName] = state.DockZoneID;
    e.Indices[state.UniqueName] = state.Index;
    }
    ......
    }
  8. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 28 Apr 2009 Link to this post

    List<DockState> states = RadDockLayout1.GetRegisteredDocksState() will return all registered RadDock states.
    You could get a particular state with this code:   DockState state = RadDockLayout1.GetRegisteredDocksState()[0];
    states[i]  is a single RadDock's state

  9. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 28 Apr 2009 Link to this post

    Thanks for the reply Obi Wan,

    I still get a compile error, this time is doesn't know what "i" is, when i dim it to an integer I get a new error. here is my block of code.

     

    Dim states As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()

     

     

    Dim state As DockState = DockState.Deserialize(states(i))

     

     

    Dim dock As RadDock = DirectCast(RadDockLayout1.FindControl(state.UniqueName), RadDock)

     

    dock.ApplyState(state)

    e.Positions(state.UniqueName) = state.DockZoneID

    e.Indices(state.UniqueName) = state.Index


    here is the error when i dim it to an int.

    "Error 19 Value of type 'Telerik.Web.UI.DockState' cannot be converted to 'String'."



    Thanks For your help.

  10. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 29 Apr 2009 Link to this post

    Anyone have an answer on this?
  11. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 01 May 2009 Link to this post

    Dim states As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()

    - states is List of DockStates

     So this is wrong:

     

    Dim state As DockState = DockState.Deserialize(states(i))
    because:
    states(i) type is DockState  but DockState.Deserialize(STRING);


    If you want to serialize a DockState, you should use:  Dim stateString As String  = stateList[i].ToString()
    otherwise you should use:                                         DockState.Deserialize(stateString);

  12. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 01 May 2009 Link to this post

    Thanks for the reply, can you post the entire block of code? Here is my code based on what I have gotten out of this forum but it won't compile.

     

     

     

     

    Dim states As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()

     

     

     

    Dim state As DockState = DockState.Deserialize(states(i))

     

     

     

    Dim dock As RadDock = DirectCast(RadDockLayout1.FindControl(state.UniqueName), RadDock)

     

    dock.ApplyState(state)

    e.Positions(state.UniqueName) = state.DockZoneID

    e.Indices(state.UniqueName) = state.Index

     

     

     

     

  13. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 01 May 2009 Link to this post

    I've got it down to this but I'm right back where I was last week........ "i" is not defined. Can someone please look at this block of code and tell me how to fix it?????

    Dim

     

    stateList As List(Of DockState) = DirectCast(sender, RadDockLayout).GetRegisteredDocksState()

     

     

    Dim stateString As String = stateList(i).ToString()

     

     

    Dim state As DockState = DockState.Deserialize(stateString)

     

     

    Dim dock As RadDock = DirectCast(RadDockLayout1.FindControl(state.UniqueName), RadDock)

     

    dock.ApplyState(state)

    e.Positions(state.UniqueName) = state.DockZoneID

    e.Indices(state.UniqueName) = state.Index

  14. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 01 May 2009 Link to this post

    "i" is not defined - because "i" is not defined.

    The code should be:

     Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()  
            Dim i As Integer = 0  
            While i < stateList.Count  
                Dim stateString As String = stateList(i).ToString()  
                i = i + 1  
            End While 

    Or you could use For Each:

    Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()  
            For Each state As DockState In stateList  
                Dim stateString As String = state.ToString()  
            Next 

    You could read about the List class here:
    http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx
  15. Sam
    Sam avatar
    103 posts
    Member since:
    Feb 2009

    Posted 01 May 2009 Link to this post

    I got the entire code blaock to compile, I'll post it for anyone wanting the complete solution, how ever it isn't saving the collapsed or closed state....... I am pulling the controls dynamically from a database and populating the rad dock with user controls, any one know why this might be happening? Im not saving the state in the database, im using the cookie based state.

    Thanks,
    Sam

    Code

     

    Dim stateList As List(Of DockState) = RadDockLayout1.GetRegisteredDocksState()

     

     

    Dim stateString As String

     

     

    Dim i As Integer = 0

     

     

    While i < stateList.Count

     

    stateString = stateList(i).ToString()

    i = i + 1

     

    End While

     

     

    Dim state As DockState = DockState.Deserialize(stateString)

     

     

    Dim dock As RadDock = DirectCast(RadDockLayout1.FindControl(state.UniqueName), RadDock)

     

    dock.ApplyState(state)

    e.Positions(state.UniqueName) = state.DockZoneID

    e.Indices(state.UniqueName) = state.Index




    /Code
  16. Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 05 May 2009 Link to this post

    If you collapse or close a RadDock you should make an additional ajax call/postback to save its state.
    You could find a simple example which illustrates how to save the state on each move/collapse/expand/close here:
    http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx
  17. Maas Prog
    Maas Prog avatar
    48 posts
    Member since:
    Oct 2005

    Posted 04 Mar 2010 Link to this post

    HI All - I was having same question and documentation is confusing at best for some of us... Here is what finally worked for me:
      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 dockstate As String = ""
            Using db As New promptUser
                dockstate = db.GetProjectDockState(nProjectID)
            End Using
            If dockstate <> "" Then
                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)

                        Dim dock As RadDock = RadDockLayout1.FindControl(state.UniqueName)
                        dock.ApplyState(state)
                        
                        e.Positions(state.UniqueName) = state.DockZoneID
                        e.Indices(state.UniqueName) = state.Index

                    End If
                Next
            End If
            
     
          'Reset the non changeable dock properties
            dockProjectOverview.Height = Unit.Pixel(400)
            CreateSaveStateTrigger(dockProjectOverview)
            
            dockBudgetOverview.Height = Unit.Pixel(375)
            CreateSaveStateTrigger(dockBudgetOverview)
            
            dockNotes.Height = Unit.Pixel(250)
            CreateSaveStateTrigger(dockNotes)
            
            dockTeamMembers.Height = Unit.Pixel(250)
            CreateSaveStateTrigger(dockTeamMembers)

        End Sub
        
        Private Sub CreateSaveStateTrigger(ByVal dock As RadDock)
            'Ensure that the RadDock control will initiate postback
            ' when its position changes on the client or any of the commands is clicked.
            'Using the trigger we will "ajaxify" that postback.
            dock.AutoPostBack = True
            dock.CommandsAutoPostBack = True

            Dim saveStateTrigger As New AsyncPostBackTrigger()
            saveStateTrigger.ControlID = dock.ID
            saveStateTrigger.EventName = "DockPositionChanged"
            UpdatePanel1.Triggers.Add(saveStateTrigger)

            saveStateTrigger = New AsyncPostBackTrigger()
            saveStateTrigger.ControlID = dock.ID
            saveStateTrigger.EventName = "Command"
            UpdatePanel1.Triggers.Add(saveStateTrigger)
        End Sub


    And in the ASPX page i put this right at the end of the layout tags:
                 <div style="width: 0px; height: 0px; overflow: hidden; position: absolute; left: -10000px;">
                    Hidden UpdatePanel, which is used to help with saving state when minimizing, moving
                    and closing docks. This way the docks state is saved faster (no need to update the
                    docking zones).
                    <asp:UpdatePanel runat="server" ID="UpdatePanel1">
                    </asp:UpdatePanel>
                    </div>


    Hope this helps -- ford

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017