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

Losing dynamically created DockZone state.

1 Answer 49 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 2
Sean asked on 18 Jan 2011, 11:59 PM
Hi all,

I have been using Telerik's tutorials on how to dynamically add docks to a dock zone. Inside of my dock is a chart which has drill-down capability. I do not seem to be doing something correctly, however. When the user interacts with the chart (it seems) that some of the dock's initially set properties are being forgotten.

Image: http://i.imgur.com/3Qrqn.png

The upper image is a freshly created dock zone. The second image is moments after the user clicked a series on the chart and 'drilled down.' I placed breakpoints throughout my code and it seems that the upper bar is disappearing before Page_Init is called.

In addition, if the user refreshes the page or grabs the dock and drags it, then allows it to drop back onto the dock zone, it resets to its initial state. The title bar becomes present again.

Here is the relevant code I have written:

protected void RadListBox_Dropped(object sender, RadListBoxDroppedEventArgs e)
{
    foreach( RadListBoxItem item in e.SourceDragItems)
    {
        RadDock dock = CreateRadDock();
        dock.Tag = item.Text;
        dock.Title = dock.Tag + CurrentDockStates.Count.ToString();
        RadDockZone1.Controls.Add(dock);
        CreateSaveStateTrigger(dock);
         
        LoadContent(dock);
    }
}

private RadDock CreateRadDock()
{
    RadDock dock = new RadDock();
    dock.DockMode = DockMode.Docked;
    dock.UniqueName = Guid.NewGuid().ToString().Replace("-", "a"); //Why am I replacing with 'a' here?
    dock.ID = string.Format("RadDock{0}", dock.UniqueName);
    dock.Title = "Dock";
    dock.Skin = RadDockLayout1.Skin;
    dock.Width = Unit.Pixel(200);
    dock.EnableRoundedCorners = true;
 
    return dock;
}

private void CreateSaveStateTrigger(RadDock dock)
{
    dock.AutoPostBack = true;
    dock.CommandsAutoPostBack = true;
 
    AsyncPostBackTrigger saveStateTrigger = 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);
}

private void LoadContent(RadDock dock)
{
    switch (dock.Tag)
    {
        case "Cat 5e Capacity":
            System.Web.UI.Control ctrl = Page.LoadControl("PowerUsage.ascx");
            dock.ContentContainer.Controls.Add(ctrl);
            break;
    }
}

RadDockLayout1_SaveDockLayout, LoadDockLayout, CurrentDockStates, CreateRadDockFromState are identical to those given in your examples. I believe the above should all be mostly identical, if not identical, as well. 

The only difference I can see between my example and http://demos.telerik.com/aspnet-ajax/dock/examples/myportal/defaultcs.aspx is that my example does not use a 2nd UpdatePanel. Instead, I am using the RadAjaxManager to refresh the view after a user has drag/dropped/created a dock. 

Does this seem correct? Can I provide more information?

Sean

EDIT: I see why the state of the graph reverts to its top level view. During page_init all the docks call LoadContent again to, in theory, reload the content they were displaying before. In practice, a user has navigated one level deep into the chart and then LoadContent is called -- this retrieves the top level of the chart, not one level deep. Any advice on how to handle this scenario would be much appreciated -- I do not see a great way of handling this.

1 Answer, 1 is accepted

Sort by
0
Accepted
Pero
Telerik team
answered on 21 Jan 2011, 03:09 PM
Hi Sean,

I created a sample project to try to reproduce the issue locally, but to no avail. I used RadChart with drill-down functionality. Please find the sample attached to the thread. The project is based on the MyPortal demo with the following changes:
  • Removed the invisible update panel, and made the other panel with UpdateMode="Always".
  • The dock are always added to the RadDockLayout, because the Chart relies on ViewState, and the dynamically create controls must be added to one and the same control all the time.
Could you please send a sample project that demonstrates the issue, so we can observe it locally?
 
Greetings,
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.
Tags
Dock
Asked by
Sean
Top achievements
Rank 2
Answers by
Pero
Telerik team
Share this question
or