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

Dynamic Docks and Saving State

6 Answers 202 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 17 Jan 2008, 12:47 AM
Hello Telerik guys,
I have a problem with saving the state of dynamically created docks. 
GetRegisteredDocksState() always seems to fetch back the original state and is causing me a real headache.  Ive uploaded the source files to http://www.tidy.com/DynamicDocks.zip
Any help on this would be appreciated.
Alex.

6 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 17 Jan 2008, 12:43 PM
Hi Alex,

I reviewed your project and my suggestion is to stick as close as possible to the following online demos:

http://www.telerik.com/DEMOS/ASPNET/Prometheus/Dock/Examples/DynamicDocks/DefaultCS.aspx
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Dock/Examples/MyPortal/DefaultCS.aspx

where the docks are added to the RadDockLayout and you need to set each dock's DockZoneID property. Also make sure the docks are created on Init. In your project you can get reference to the RadDockLayout1 from your master page in your module_layout_column.ascx with
Dim layout As RadDockLayout = Page.Master.FindControl("RadDockLayout1")

Hope this helps.

Kind regards,
Petya
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Alex
Top achievements
Rank 1
answered on 22 Jan 2008, 03:35 PM
Thanks Telerik,
that worked a treat, my headache has completely gone away : )
Alex.
0
Michelle
Top achievements
Rank 1
answered on 10 Oct 2008, 09:27 AM
Hi Petya

I have use the example in
http://demos.telerik.com/ASPNET/Prometheus/Dock/Examples/DynamicDocks/DefaultCS.aspx

One problem regarding it is even though I have close the dock object, the dock object will still appear when i manually refresh the page.

One of my solution to it is to add an event handler to remove the selected session object  to the close button. However due to .net life cycle, the page_load is process before event. Thus when the page load, it cannot detect that one of the session is already removed. Thus an error of "Index out of range" will be prompt.

Is there any other alternative to it?

Cheers
Michelle




0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 10 Oct 2008, 12:47 PM
The state is not saved once you close the RadDock. You should perform a postback/ajax call to save the state.

An example which illustrates how to save the state on every dock move or dock close, is available here:
http://demos.telerik.com/ASPNET/Prometheus/Dock/Examples/MyPortal/DefaultCS.aspx
0
Michelle
Top achievements
Rank 1
answered on 13 Oct 2008, 01:29 AM
Hi Kenobi

Thanks for the promptly reply.

I have tried the example, but when I add in the headtag " namespace="Telerik.QuickStart " they will prompt assembly not found.

On the other hand I tried the example below. Everything works fine except that when i add a new dock(on click add button), RadDockingManager is unable to save the state of the new dock. What's wrong with the code below?
===================================================
using Telerik.WebControls;
using Telerik.RadMenuUtils;
using Telerik.RadDockUtils;

public partial class SavingDock : System.Web.UI.Page
{
    private void Page_Load(object sender, System.EventArgs e)
        {
            if (!IsPostBack)
            {
                object state = this.Application["RadDockState"];
                if (state is string)
                {
                    RadDockingManager1.LoadState((string)state);
                }
            }
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            InitializeComponent();
            base.OnInit(e);
        }

        private void InitializeComponent()
        {
            this.Load += new System.EventHandler(this.Page_Load);
            btnSaveState.Click += new EventHandler(btnSaveState_Click);
            btnAddDock.Click += new EventHandler(btnAddDock_Click);
         }
        #endregion

        private void btnSaveState_Click(object sender, EventArgs e)
        {
            this.Application["RadDockState"] = RadDockingManager1.SaveState();
            object state = this.Application["RadDockState"];
            RadDockingManager1.LoadState((string)state);
        }

        protected void btnAddDock_Click(object sender, EventArgs e)
        {
            RadDockableObject dockableObj = new RadDockableObject();
            dockableObj.Text = "Test";
            dockingZone.Controls.Add(dockableObj);
            this.Application["RadDockState"] = RadDockingManager1.SaveState();
        }
}
==================================================
0
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 13 Oct 2008, 08:29 AM
namespace="Telerik.QuickStart  is related to the Examples provided by Telerik, so you shouldn't use it.

You use  the RadDock for ASP.NET control.The RadDockManager.SaveState and LoadState methods are only for declaratively created RadDocks. If you want to save the state for dynamically created RadDocks you should create your own mechanism.

My suggestion is to use the RadDock for ASP.NET AJAX control(completely new RadDock). Simple examples which illustrate how to save/load state of dynamically created RAdDocks is available here:
1)http://demos.telerik.com/ASPNET/Prometheus/Dock/Examples/DynamicDocks/DefaultCS.aspx
2)
http://demos.telerik.com/ASPNET/Prometheus/Dock/Examples/MyPortal/DefaultCS.aspx
Tags
Dock
Asked by
Alex
Top achievements
Rank 1
Answers by
Petya
Telerik team
Alex
Top achievements
Rank 1
Michelle
Top achievements
Rank 1
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or