RadDock Problem !

3 posts, 1 answers
  1. A.mass
    A.mass avatar
    30 posts
    Member since:
    Apr 2009

    Posted 10 Apr 2009 Link to this post



    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. A.mass
    A.mass avatar
    30 posts
    Member since:
    Apr 2009

    Posted 11 Apr 2009 Link to this post



    Anyone got a solution to this problem ?!
  3. Answer
    Obi-Wan Kenobi
    Obi-Wan Kenobi  avatar
    460 posts
    Member since:
    Aug 2007

    Posted 13 Apr 2009 Link to this post

    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);  
                        }  
                    }  
                }  
            }  
        }     
     

Back to Top