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

RadDock Problem !

2 Answers 137 Views
Dock
This is a migrated thread and some comments may be shown as answers.
A.mass
Top achievements
Rank 1
A.mass asked on 10 Apr 2009, 05:11 PM


Hello everyone,

I'm facing a problem with RadDock, the following what I'm trying to do:

There're 4 docks in 2 Zones, the user can close these, and when the user close it the name of the closed Docks will be in a dropdownlist, if the user selected that name the dock will be visible again.
[ I tried to read all the online and offile docs to solve it but I couldn't ]

this is my code to apply this : 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestingThis.aspx.cs" Inherits="TestingThis" %> 
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title></title>  
    <style type="text/css">  
        .style1  
        {  
            width: 100%;  
        }  
    </style> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
        <ContentTemplate> 
            <telerik:RadDockLayout ID="RadDockLayout1" Runat="server" Skin="Hay"   
        onloaddocklayout="RadDockLayout1_LoadDockLayout"   
        onsavedocklayout="RadDockLayout1_SaveDockLayout">  
                Show Box  
                <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"   
                    style="direction: ltr">  
                </asp:DropDownList> 
                &nbsp;<table class="style1">  
                    <tr> 
                        <td> 
                            <telerik:RadDockZone ID="RadDockZone1" Runat="server" MinWidth="">  
                                <telerik:RadDock ID="RadDock1" Runat="server" Width="300px" AutoPostBack="true" 
                            CommandsAutoPostBack="True">  
                            <TitlebarTemplate>Attendance Report</TitlebarTemplate> 
                                    <ContentTemplate> 
                                        This is RadDock 1  
                                    </ContentTemplate> 
                                </telerik:RadDock> 
                                <telerik:RadDock ID="RadDock2" Runat="server" Width="300px" AutoPostBack="true"   
                            CommandsAutoPostBack="True">  
                                    <ContentTemplate> 
                                        This is RadDock 2  
                                    </ContentTemplate> 
                                </telerik:RadDock> 
                            </telerik:RadDockZone> 
                        </td> 
                        <td> 
                            <telerik:RadDockZone ID="RadDockZone2" Runat="server" MinWidth="">  
                                <telerik:RadDock ID="RadDock3" Runat="server" Width="300px" AutoPostBack="true"   
                            CommandsAutoPostBack="True">  
                                    <ContentTemplate> 
                                        This is RadDock 3  
                                    </ContentTemplate> 
                                </telerik:RadDock> 
                                <telerik:RadDock ID="RadDock4" Runat="server" Width="300px" AutoPostBack="true"   
                            CommandsAutoPostBack="True">  
                                    <ContentTemplate> 
                                        This is RadDock 4  
                                    </ContentTemplate> 
                                </telerik:RadDock> 
                            </telerik:RadDockZone> 
                        </td> 
                    </tr> 
                </table> 
            </telerik:RadDockLayout> 
        </ContentTemplate> 
    </asp:UpdatePanel> 
    </form> 
</body> 
</html> 
 


 

using System;  
using System.Collections.Generic;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using Telerik.Web.UI;  
using System.Text;  
 
public partial class TestingThis : System.Web.UI.Page  
{  
    protected void RadDockLayout1_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)  
    {  
        if (!Page.IsPostBack)  
        {  
            HttpCookie positionsCookie = Request.Cookies.Get("positionsCookie");  
            if (positionsCookie != null)  
            {  
                String serializedList = positionsCookie.Value;  
                if (serializedList != null)  
                {  
                    String[] states = serializedList.Split('|');  
 
                    for (int i = 0; i < states.Length - 1; i++)  
                    {  
                        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;  
                    }  
                }  
            }  
        }  
    }  
 
    protected void RadDockLayout1_SaveDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)  
    {  
        HttpCookie positionsCookie = new HttpCookie("positionsCookie");  
        Page.Response.Cookies.Add(positionsCookie);  
 
        List<DockState> stateList = ((RadDockLayout)sender).GetRegisteredDocksState();  
        StringBuilder serializedList = new StringBuilder();  
 
        for (int i = 0; i < stateList.Count; i++)  
        {  
            if (stateList[i].UniqueName == DropDownList1.SelectedValue.ToString())  
            {  
                RadDock dock = (RadDock)RadDockLayout1.FindControl(stateList[i].UniqueName);  
                dock.Closed = false;  
                DropDownList1.Items.Remove(DropDownList1.Items.FindByValue(DropDownList1.SelectedValue));  
            }  
            serializedList.Append(stateList[i].ToString());  
            serializedList.Append("|");  
        }  
        positionsCookie.Expires = DateTime.MaxValue;  
        positionsCookie.Value = serializedList.ToString();  
 
 
        if (Page.IsPostBack)  
        {  
            DropDownList1.Items.Clear();  
            BindDropDown();  
        }  
    }  
 
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!this.IsPostBack)  
        {  
            BindDropDown();  
        }  
    }  
 
    private void BindDropDown()  
    {  
        HttpCookie positionsCookie = Request.Cookies.Get("positionsCookie");  
        if (positionsCookie != null)  
        {  
            String serializedList = positionsCookie.Value;  
            if (serializedList != null)  
            {  
                String[] states = serializedList.Split('|');  
 
                for (int i = 0; i < states.Length - 1; i++)  
                {  
                    ListItem item;  
                    DockState state = DockState.Deserialize(states[i]);  
                    RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName);  
                      
                    if (i == 0)  
                    {  
                        item = new ListItem();  
 
                        item.Text = "-------------";  
                        item.Value = "-------------";  
 
                        DropDownList1.Items.Add(item);  
                    }  
 
                    if (dock.Closed)  
                    {  
                        item = new ListItem();  
                        item.Text = state.UniqueName;  
                        item.Value = state.UniqueName;  
                        DropDownList1.Items.Add(item);  
                    }  
                }  
            }  
        }  
    }  


I dont know if I'm missing something or its a bug !

Thanks in advance.            



2 Answers, 1 is accepted

Sort by
0
A.mass
Top achievements
Rank 1
answered on 11 Apr 2009, 10:15 AM


Anyone got a solution to this problem ?!
0
Accepted
Obi-Wan Kenobi
Top achievements
Rank 1
answered on 13 Apr 2009, 01:06 PM

I modified your code and it works now.
ASPX

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title></title>  
    <style type="text/css">  
        .style1  
        {  
            width: 100%;  
        }  
    </style> 
</head> 
<body> 
    <form id="form1" runat="server">  
    <asp:ScriptManager ID="ScriptManager1" runat="server">  
    </asp:ScriptManager> 
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">     
        <ContentTemplate> 
    <telerik:RadDockLayout ID="RadDockLayout1" runat="server" Skin="Hay" OnLoadDockLayout="RadDockLayout1_LoadDockLayout" 
        OnSaveDockLayout="RadDockLayout1_SaveDockLayout">  
        Show Box  
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" 
            Style="direction: ltr">  
        </asp:DropDownList> 
        &nbsp;<table class="style1">  
            <tr> 
                <td> 
                    <telerik:RadDockZone ID="RadDockZone1" runat="server" MinWidth="">  
                        <telerik:RadDock ID="RadDock1" runat="server" Width="300px" AutoPostBack="true" OnCommand="DockCommand">  
                            <Commands> 
                                <telerik:DockCloseCommand AutoPostBack="true" /> 
                            </Commands> 
                            <TitlebarTemplate> 
                                Attendance Report</TitlebarTemplate> 
                            <ContentTemplate> 
                                This is RadDock 1  
                            </ContentTemplate> 
                        </telerik:RadDock> 
                        <telerik:RadDock ID="RadDock2" runat="server" Width="300px" AutoPostBack="true" OnCommand="DockCommand">  
                            <Commands> 
                                <telerik:DockCloseCommand AutoPostBack="true" /> 
                            </Commands> 
                            <ContentTemplate> 
                                This is RadDock 2  
                            </ContentTemplate> 
                        </telerik:RadDock> 
                    </telerik:RadDockZone> 
                </td> 
                <td> 
                    <telerik:RadDockZone ID="RadDockZone2" runat="server" MinWidth="">  
                        <telerik:RadDock ID="RadDock3" runat="server" Width="300px" AutoPostBack="true" OnCommand="DockCommand">  
                            <Commands> 
                                <telerik:DockCloseCommand AutoPostBack="true" /> 
                            </Commands> 
                            <ContentTemplate> 
                                This is RadDock 3  
                            </ContentTemplate> 
                        </telerik:RadDock> 
                        <telerik:RadDock ID="RadDock4" runat="server" Width="300px" AutoPostBack="true" OnCommand="DockCommand">  
                            <Commands> 
                                <telerik:DockCloseCommand AutoPostBack="true" /> 
                            </Commands> 
                            <ContentTemplate> 
                                This is RadDock 4  
                            </ContentTemplate> 
                        </telerik:RadDock> 
                    </telerik:RadDockZone> 
                </td> 
            </tr> 
        </table> 
    </telerik:RadDockLayout> 
    </ContentTemplate>    
    </asp:UpdatePanel> 
    </form> 
</body> 
</html> 
 

Codebehind:

  protected void RadDockLayout1_LoadDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)  
    {  
        if (!Page.IsPostBack)  
        {  
            HttpCookie positionsCookie = Request.Cookies.Get("positionsCookie");  
            if (positionsCookie != null)  
            {  
                String serializedList = positionsCookie.Value;  
                if (serializedList != null)  
                {  
                    String[] states = serializedList.Split('|');  
 
                    for (int i = 0; i < states.Length - 1; i++)  
                    {  
                        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;  
                    }  
                }  
            }  
        }  
    }  
 
    protected void RadDockLayout1_SaveDockLayout(object sender, Telerik.Web.UI.DockLayoutEventArgs e)  
    {  
        HttpCookie positionsCookie = new HttpCookie("positionsCookie");  
        Page.Response.Cookies.Add(positionsCookie);  
 
        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("|");  
        }  
        positionsCookie.Expires = DateTime.MaxValue;  
        positionsCookie.Value = serializedList.ToString();  
 
 
        //if (Page.IsPostBack)  
        //{  
        //    DropDownList1.Items.Clear();  
        //    BindDropDown();  
        //}  
    }  
    protected void DockCommand(object sender, DockCommandEventArgs args)  
    {  
        if (args.Command.Name == "Close")  
        {  
            RadDock dock = (RadDock)sender;  
            ListItem item = new ListItem();  
            item.Text = dock.UniqueName;  
            item.Value = dock.UniqueName;  
            DropDownList1.Items.Add(item);  
        }  
    }  
 
    protected void Page_Load(object sender, EventArgs e)  
    {  
        if (!this.IsPostBack)  
        {  
            BindDropDown();  
        }  
    }  
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)  
    {  
        string selectedUniqueName = DropDownList1.SelectedValue;  
        RadDock dock = (RadDock)RadDockLayout1.FindControl(selectedUniqueName);  
        dock.Closed = false;  
        DropDownList1.Items.Remove(DropDownList1.Items.FindByValue(DropDownList1.SelectedValue));  
          
    }  
 
    private void BindDropDown()  
    {  
        HttpCookie positionsCookie = Request.Cookies.Get("positionsCookie");  
        if (positionsCookie != null)  
        {  
            String serializedList = positionsCookie.Value;  
            if (serializedList != null)  
            {  
                String[] states = serializedList.Split('|');  
 
                for (int i = 0; i < states.Length - 1; i++)  
                {  
                    ListItem item;  
                    DockState state = DockState.Deserialize(states[i]);  
                    RadDock dock = (RadDock)RadDockLayout1.FindControl(state.UniqueName);  
 
                    if (i == 0)  
                    {  
                        item = new ListItem();  
 
                        item.Text = "-------------";  
                        item.Value = "-------------";  
 
                        DropDownList1.Items.Add(item);  
                    }  
 
                    if (dock.Closed)  
                    {  
                        item = new ListItem();  
                        item.Text = state.UniqueName;  
                        item.Value = state.UniqueName;  
                        DropDownList1.Items.Add(item);  
                    }  
                }  
            }  
        }  
    }     
 

Tags
Dock
Asked by
A.mass
Top achievements
Rank 1
Answers by
A.mass
Top achievements
Rank 1
Obi-Wan Kenobi
Top achievements
Rank 1
Share this question
or