Hi,
I am creating windows dynamically based on the settings I retrieve from database. Need to add some custom properties to the RadWindows so that I can use them while rendering to make decissions, like whether to show it in the minimized mode after its visible(because I've many rad windows popping up on the screen). Attributes which will drive the minimum width and height of the windows, which I'll use in the resize event of the RadWindows.
I've a code sample here, kindly help me understand how I can do this.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %> |
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> |
<!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> |
<script type="text/javascript"> |
function WindowCreatedAndShowed(sender, args) { |
if (sender.isMinimized == "True") { |
sender.hide(); |
} |
} |
</script> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadWindowManager ShowOnTopWhenMaximized="false" Width="100%" Height="100%" |
OnClientActivate="OnClientActivate" OnClientClose="OnClientClose" Behaviors="Close,Maximize,Minimize,Move,Reload,Resize" |
OnClientCommand="OnClientCommand" ID="DBRadWindowManager" RestrictionZoneID="RestrictionZone" |
runat="server" Skin="Telerik" OnClientPageLoad="WindowCreatedAndShowed" OnClientResize="OnClientResize"> |
</telerik:RadWindowManager> |
</form> |
</body> |
</html> |
Code Behind:
using System; |
using System.Collections.Generic; |
using System.Linq; |
using System.Web; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using Telerik.Web.UI; |
namespace WebApplication2 |
{ |
public partial class _Default : System.Web.UI.Page |
{ |
protected void Page_Load(object sender, EventArgs e) |
{ |
if (!Page.IsPostBack) |
{ |
try |
{ |
//Get the currently logged in user's Tab-Widgets collection |
List<Tab> objTabsCollection = GetUserTabsWidgetsCollection(); //Gets the data |
if (objTabsCollection != null && objTabsCollection.Count > 0) |
{ |
int tabCounter = 1; |
//Loop through all the Tabs the user is authorized to view, add the Tabs to the MainTabStrip, |
//Add PageView to each of the Main tab, Add TabStrip to each of the PageView (Widget level Tabstrip), |
//Add Widgets to the WindowManager collection to add the association with the widget tabstrip |
foreach (Tab objEntityMainTab in objTabsCollection) |
{ |
//If it is the first tab, then make widgets visible, set the tab to the selected tab and |
//set the PageView of the tab to selected. |
if (tabCounter++ == 1) |
{ |
//Add widgets associated with the Main tab |
AddWidgetsForEachMainTab(objEntityMainTab, true); |
} |
else |
{ |
AddWidgetsForEachMainTab(objEntityMainTab, false); |
} |
} |
} |
else |
{ |
Server.Transfer(string.Format("{0}Item=You are not authorized to view any pages in this application.", UnauthorizedPagePath)); |
} |
} |
catch (Exception ex) |
{ |
//Exception Handling |
} |
} |
} |
/// <summary> |
/// Adds the Widgets associated with given Main tab |
/// </summary> |
/// <param name="objUIMainTab">Main tab for which the associated widgets need to be added</param> |
/// <param name="objEntityMainTab">Entity Tab object that consists of the Widgets information for the Main tab</param> |
/// <param name="isWidgetVisible">Tells if the widgets needs to be visible on initial page load</param> |
private void AddWidgetsForEachMainTab(Tab objEntityMainTab, bool isWidgetVisible) |
{ |
short tabIndex = 1; |
//Create Tab & associated RadWindows for each of the sub tab in the Main tab |
foreach (Widget objWidget in objEntityMainTab.Widgets) |
{ |
//Create RadWindow for the Tab |
RadWindow objTabWindow = new RadWindow(); |
objTabWindow.ID = objWidget.Widget_Name.ToUpper() + "_WINDOW"; |
objTabWindow.VisibleOnPageLoad = true; |
objTabWindow.TabIndex = tabIndex++; |
objTabWindow.BorderStyle = BorderStyle.None; |
objTabWindow.Behaviors = WindowBehaviors.Default; |
objTabWindow.Height = Unit.Pixel(objWidget.Initial_Height); |
objTabWindow.InitialBehaviors = WindowBehaviors.None; |
objTabWindow.Left = Unit.Pixel(objWidget.Widget_Left); |
objTabWindow.ReloadOnShow = true; |
objTabWindow.Skin = "Telerik"; |
objTabWindow.Title = objWidget.Widget_Name; |
objTabWindow.Top = Unit.Pixel(objWidget.Widget_Top); |
objTabWindow.Width = Unit.Pixel(objWidget.Initial_Width); |
objTabWindow.IconUrl = "~/images/bg-header-widget.gif"; |
objTabWindow.NavigateUrl = objWidget.Widget_NavigateURL; |
objTabWindow.Behaviors = WindowBehaviors.Minimize | WindowBehaviors.Maximize | WindowBehaviors.Move | WindowBehaviors.Reload | WindowBehaviors.Resize; |
objTabWindow.KeepInScreenBounds = true; |
objTabWindow.VisibleOnPageLoad = isWidgetVisible; |
objTabWindow.Visible = true; |
objTabWindow.VisibleStatusbar = false; |
//Attributes for the Minimum Height and Width for each of the widgets |
//along with the value if the widgets needs to be in minimized state while loading |
objTabWindow.Attributes.Add("isMinimized", objWidget.IsMinimized ? Boolean.FalseString : Boolean.TrueString); |
objTabWindow.Attributes.Add("MinimunHeight", Convert.ToString(objWidget.Minimum_Height)); |
objTabWindow.Attributes.Add("MinimunWidth", Convert.ToString(objWidget.Minimum_Width)); |
//Add the newly created RadWindow to the RadWindowManager |
DBRadWindowManager.Windows.Add(objTabWindow); |
} |
} |
} |
//Tab & Widget classes definition |
public class Tab |
{ |
public int Tab_Id { get; set; } |
public string TabName { get; set; } |
public string CreateID { get; set; } |
public List<Widget> Widgets { get; set; } |
} |
public class Widget |
{ |
public int Widget_Id {get;set;} |
public string Widget_Name {get;set;} |
public string Widget_NavigateURL {get;set;} |
public bool IsMinimized {get;set;} |
public int Widget_Left {get;set;} |
public int Widget_Top {get;set;} |
public int Initial_Height {get;set;} |
public int Initial_Width {get;set;} |
public int Minimum_Width {get;set;} |
public int Minimum_Height {get;set;} |
} |
} |