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

Save Layout After Page_Load

3 Answers 60 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 18 Sep 2012, 08:38 PM
Hello, everyone.

I'm having an issue with the RadDock and the page's lifecycle.  Using the online demos as a template, I'm trying to load and save some user-requested docks in some different RadDockZones.  The problem I'm having is since I have a couple of other dynamic controls that load during the Page_Load event, I can never seem to get the RadLayout's SaveDockLayout to fire properly.  I'm able to load several docks into a couple of different zones with no problem, but when I go to move one, it reverts back to its original position and the only thing I can think of is because of the postback that's happening. I know that the SaveDockLayout event fires after the Page_Load, but I'm confused as to how I can properly save the layout if it's already rendering back to its prior instance.

3 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 21 Sep 2012, 12:33 PM
Hi Demetrus,

I would suggest checking the help articles SaveDockLayout and LoadDockLayout for more information and examples on using these events to store and load the layout state of the existing RadDock controls that are placed in the RadDockLayout.

In this help article you can examine the steps for dynamically creating docks and persisting their state by using the RadDockLayout events mentioned above. You should be able to implement your scenario if you follow the described approach. Note that it is used in the examples that can be found in the online demos Dynamically Created Docks and My Portal.

I hope this helps. Feel free to contact us again if you encounter more difficulties.

Greetings,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Steve
Top achievements
Rank 1
answered on 24 Sep 2012, 03:54 PM
Hi, Slav.

Thank you for responding. I looked at that help page and the examples before I posted my question.  I believe the issue I'm having is this: I'm dynamically creating a grid of controls for a user to select based up on their job role.  When they click on a control, I have a RadContextMenu show and they can select which zone to create the dock in.  This piece works fine, but whenever they create another dock using the same method, the first goes away and the second is created.  I've checked my SaveDockLayout and LoadDockLayout handlers against the code examples, and they're OK (meaning, my code matches what's online).  I'm trying to use the same concept as the MyPortal example, so I'm wondering if there's something triggering the AJAX call and not the save/load handlers (my AJAX triggers are tied to the ContextMenu's ItemClick event).

Thanks again for your help!
0
Slav
Telerik team
answered on 27 Sep 2012, 08:56 AM
Hello Demetrus,

The page goes through its whole page lifecycle even when an AJAX request is initiated so the events SaveDockLayout and LoadDockLayout of RadDockLayout are fired in this case as well. Most probably the actual cause for your problem is the previously added docks not being recreated when you start a new AJAX request. This should be done on Page_Init as described in step 5.2 in the previously linked help article and it is implemented in the My Portal demo:
protected void Page_Init(object sender, EventArgs e)
{
    //Recreate the docks in order to ensure their proper operation
    for (int i = 0; i < CurrentDockStates.Count; i++)
    {
 
        RadDock dock = CreateRadDockFromState(CurrentDockStates[i]);
        //We will just add the RadDock control to the RadDockLayout.
        // You could use any other control for that purpose, just ensure
        // that it is inside the RadDockLayout control.
        // The RadDockLayout control will automatically move the RadDock
        // controls to their corresponding zone in the LoadDockLayout
        // event (see below).
        RadDockLayout1.Controls.Add(dock);
        //We want to save the dock state every time a dock is moved.
        CreateSaveStateTrigger(dock);
        //Load the selected widget
        LoadWidget(dock);
        if (CurrentDockStates[i].Closed == true)
        {
            dock.Visible = false;
        }
    }
}

Please ensure that you have included this step in your actual project. If you continue experiencing difficulties, I would suggest opening a support ticket and isolating the problem in a simple, fully runnable page so that I can inspect it locally and provide a concrete solution.

Regards,
Slav
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Dock
Asked by
Steve
Top achievements
Rank 1
Answers by
Slav
Telerik team
Steve
Top achievements
Rank 1
Share this question
or