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> |
<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.