Manually saving the layout, on a button click event

4 posts, 0 answers
  1. Chris Trina
    Chris Trina avatar
    86 posts
    Member since:
    Mar 2006

    Posted 17 Feb 2010 Link to this post

    Is there any way to save the layout of the page to a database on a user initiated event?  I've looked at all of the examples and they all seem to be based on the SaveDockLayout event.  Normally I want to allow all of this to happen via view state, but give the client the option of saving thier layout if desired via a button.  Unfortunately all of the examples seem to depend on the DockLayoutEventArgs being present. 

    Any insight would be appreciated.

    Thanks

    Chris
  2. Chris Trina
    Chris Trina avatar
    86 posts
    Member since:
    Mar 2006

    Posted 17 Feb 2010 Link to this post

    Ok, I have the saving working now, the code is shown below.  Any hints at some load state logic not tied to the event?  I want to do this at page load or prerender.

     

    Dim stateList As System.Collections.Generic.List(Of Telerik.Web.UI.DockState) = rdLayout.GetRegisteredDocksState()

     

     

    Dim serializedList As New System.Text.StringBuilder()

     

     

    Dim i As Integer = 0

     

     

    Try

     

     

    While i < stateList.Count

     

    serializedList.Append(stateList(i).ToString())

    serializedList.Append(

    "|")

     

    System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)

     

    End While

     



    then save serialized.tostring to whatever media you desire
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris Trina
    Chris Trina avatar
    86 posts
    Member since:
    Mar 2006

    Posted 17 Feb 2010 Link to this post

    ok, this shouldn't be this hard.  My situation is pretty simple, static dockzones and static docs, I simply want to let viewstate do it's thing for controling the dock layout, unless the user clicks a button to save the layout.  I believe I have this handled using code from your documentation, see an earlier post.  However, once the user saves thier layout I want to restore it the next time they come to the page.  All of the examples I can find are dependent on the loadlayout event firing which is not true in my case, and if I overload that event it messes up the normal processing via viewstate.

    Does anyone have a translation from this code which depends on e.positions and e.indices to something that is event independent?

     

    Protected Sub RadDockLayout1_LoadDockLayout( _

     

     

    ByVal sender As Object, ByVal e As DockLayoutEventArgs) _

     

     

    Handles rdLayout.LoadDockLayout

     

     

    If Not goCBCUser.PBox.PortalLayout.IsNull Then

     

     

    Dim serializedList As String = goCBCUser.PBox.PortalLayout.Value

     

     

    If serializedList <> Nothing Then

     

     

    Dim states As String() = serializedList.Split("|"c)

     

     

    Dim i As Integer = 0

     

     

    While i < states.Length

     

     

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

     

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

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

    System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)

     

    End While

     

     

    End If

     

     

    End If

     

     

    End Sub

     

  5. Chris Trina
    Chris Trina avatar
    86 posts
    Member since:
    Mar 2006

    Posted 19 Feb 2010 Link to this post

    I got everything working.  The goal was to allow view state to manage the layout, unless the user specifically choose to save thier layout, then to save the layout to a database and reload it when the page is referenced in the future.  Here is the required code for the save event and the subsequent load event.

     

    Protected Sub btnSaveLayout_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSaveLayout.Click

     

     

    Dim stateList As System.Collections.Generic.List(Of Telerik.Web.UI.DockState) = rdLayout.GetRegisteredDocksState()

     

     

    Dim serializedList As New System.Text.StringBuilder()

     

     

    Dim i As Integer = 0

     

     

    Try

     

     

    While i < stateList.Count

     

    serializedList.Append(stateList(i).ToString())

    serializedList.Append(

    "|")

     

    System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)

     

    End While

     

    ''the following 2 lines are calls to our objects for saving the data
    ''goCBCUser.PBox.PortalLayout.Value = serializedList.ToString()

    ''goCBCUser.ApplyEdit(goUser,

    False, goErrs)

     

     

    Catch ex As Exception

     

    LogUtil.LogInfo(

    "Error: TeacherPortal::btnSaveLayout_Click", ex)

     

     

    Throw ex

     

     

    End Try

     

     

    End Sub


     

     

     

     

    Protected Sub RadDockLayout1_LoadDockLayout( _

     

     

    ByVal sender As Object, ByVal e As DockLayoutEventArgs) _

     

     

    Handles rdLayout.LoadDockLayout

     

     

    Try

     

     

     

        Dim serializedList As String = goCBCUser.PBox.PortalLayout.Value

     

     

        If serializedList <> Nothing Then

     

     

     

            Dim states As String() = serializedList.Split("|"c)

     

     

            Dim i As Integer = 0

     

     

            While i < states.Length

     

     

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

     

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

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

                System.Math.Max(System.Threading.Interlocked.Increment(i), i - 1)
            

    End While

     

     

     

        End If

     

     

     

    Catch ex As Exception

     

    LogUtil.LogInfo(

    "Error: TeacherPortal::RadDockLayout1_LoadDockLayout", ex)

     

     

    Throw ex

     

     

    End Try

     

     

     

    End Sub

     

     

     

     

Back to Top