Mar 02, 2009, 2:46 PM
Need help setting the Height on Dynamic Portal/Portlet
I have a portal that I fill with portlets based on some dynamic information per each user who is looking at the site.
I have some portlets that can be added onto the site with a defined height (in pixels).
There are some where the portlet height should be as large as the iframe contents of that portlet (in my database they have a height set to -1). However, I can't seem to get the layout correct to display the portlet height when it is just supposed to be. Can anyone suggest the correct portal/portlet/fitlayout/panel configuration to show these portlet columns as 100% of their content (no more, no less).
Thanks,
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm4.aspx.vb" Inherits="HomePage.WebForm4" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Microsoft.ApplicationBlocks.Data" %>
<%@ Import Namespace="Helpers" %>
<%@ Import Namespace="Helpers.FormatHelpers" %>
<!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="Head2" runat="server">
<title>The Magazine Manager</title>
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'load the navigation menu
If Not Page.IsPostBack Then
If Not Ext.IsAjaxRequest Then
SetupHeaderToolbar()
CreatePortal(1)
End If
End If
End Sub
Private Sub SetupHeaderToolbar()
'add a separator before the nav bar
ToolBarHeader.Items.Add(New ToolbarSeparator)
'fill the rest of the space until the buttons
ToolBarHeader.Items.Add(New ToolbarFill)
'add the refresh active tab button
Dim RefreshButton As New ToolbarButton
RefreshButton.Icon = Icon.ArrowRefresh
RefreshButton.Listeners.Click.Fn = "refreshTab"
Dim ToolTipRefresh As New ToolTip
ToolTipRefresh.Html = "Refresh Tab"
RefreshButton.ToolTips.Add(ToolTipRefresh)
'ToolBarHeader.Items.Add(RefreshButton)
End Sub
Public Sub CreatePortal(ByVal PortalIndex As Integer)
'set up this portal
Dim tabPortal As Tab = FindControl("TabPortal" & PortalIndex)
tabPortal.Title = "Portal" & PortalIndex
'set the width of the portal columns
Dim ColumnLayoutTemp As ColumnLayout = FindControl(String.Format("ColumnLayoutPortal{0}_1", PortalIndex))
Dim Column1Width As Integer = 50
Dim Column2Width As Integer = 50
ColumnLayoutTemp.Columns(0).ColumnWidth = Column1Width / 100
ColumnLayoutTemp.Columns(1).ColumnWidth = Column2Width / 100
'set up column1
CreatePortletColumn(PortalIndex, 0)
'set up column2
CreatePortletColumn(PortalIndex, 1)
'create the portal
'tabPortal.Hidden = False
'tabPortal.Show()
tabPortal.DoLayout()
End Sub
Private Sub CreatePortletColumn(ByVal PortalIndex As Integer, ByVal ColumnIndex As Integer)
Dim ID As Integer
For ID = 1 To 2
Dim PortletTemp As New Portlet
Dim Title As String = String.Format("Portal{0} - Column{1} - Portlet", PortalIndex, ColumnIndex, ID)
Dim PageURL As String = "/intranet/aspnet/HomePage/webform2.aspx"
PortletTemp.ID = String.Format("Component{0}_{1}_{2}", PortalIndex, ColumnIndex, ID)
Dim Height As Integer
If ColumnIndex = 0 Then
'column 1, set the first portlet to full height
If ID = 1 Then
Height = -1
PortletTemp.Title = Title & " Height Should Be 100% of the contents"
Else
Height = 200
PortletTemp.Title = Title & " Height: " & Height
End If
Else
'column 2, set the second portlet to full height
If ID = 2 Then
Height = -1
PortletTemp.Title = Title & " Height Should Be 100% of the contents"
Else
Height = 200
PortletTemp.Title = Title & " Height: " & Height
End If
End If
If Height > 0 Then
PortletTemp.Height = Height
Else
'****************************
'if the AnchorTemp.Vertical = "100%" is set, this creates the
' portlet as much larger than the actual panel contained in the
' iframe of the portlet
PortletTemp.AutoHeight = True
'****************************
End If
'load the URL in the portlet
Dim al As New LoadConfig
al.Url = PageURL
al.ShowMask = True
al.Mode = LoadMode.IFrame
PortletTemp.Load(al)
Dim AnchorTemp As New Anchor
'***************************
'when this is added in, I get some very long pages, the portlets are drawn at thousands of pixels in height
AnchorTemp.Vertical = "100%"
'***************************
AnchorTemp.Items.Add(PortletTemp)
Dim AnchorLayoutTemp As AnchorLayout = FindControl(String.Format("AnchorLayoutPortal{0}_{1}", PortalIndex, ColumnIndex))
AnchorLayoutTemp.Anchors.Add(AnchorTemp)
Next
End Sub
</script>
<script type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" InitScriptMode="Inline">
</ext:ScriptManager>
<ext:ViewPort ID="ViewPort1" runat="server">
<Body>
<ext:BorderLayout ID="BorderLayout1" runat="server">
<North Collapsible="false">
<ext:Toolbar ID="ToolBarHeader" runat="server" Height="50" StyleSpec="padding:15px;">
</ext:Toolbar>
</North>
<Center>
<ext:Panel ID="Panel7" runat="server" AutoScroll="true">
<Body>
<ext:FitLayout ID="FitLayout2" runat="server">
<ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" Plain="true" LayoutOnTabChange="true" EnableTabScroll="true">
<Tabs>
<ext:Tab ID="TabPortal1" runat="server" Title="" ShowIFrameMask="true" AutoScroll="true">
<Body>
<ext:FitLayout ID="FitLayoutPortal11" runat="server">
<ext:Portal ID="Portal1" runat="server" Border="true" AutoHeight="true" AutoWidth="true">
<Body>
<ext:ColumnLayout ID="ColumnLayoutPortal1_1" runat="server">
<ext:LayoutColumn>
<ext:PortalColumn ID="PortalColumnPortal1_1" runat="server" StyleSpec="padding:2px 1px 2px 2px">
<Body>
<ext:AnchorLayout ID="AnchorLayoutPortal1_0" runat="server">
</ext:AnchorLayout>
</Body>
</ext:PortalColumn>
</ext:LayoutColumn>
<ext:LayoutColumn>
<ext:PortalColumn ID="PortalColumnPortal1_2" runat="server" StyleSpec="padding:2px 2px 2px 1px">
<Body>
<ext:AnchorLayout ID="AnchorLayoutPortal1_1" runat="server">
</ext:AnchorLayout>
</Body>
</ext:PortalColumn>
</ext:LayoutColumn>
</ext:ColumnLayout>
</Body>
</ext:Portal>
</ext:FitLayout>
</Body>
</ext:Tab>
</Tabs>
</ext:TabPanel>
</ext:FitLayout>
</Body>
</ext:Panel>
</Center>
</ext:BorderLayout>
</Body>
</ext:ViewPort>
</form>
</body>
</html>
The contents of each portlets iFrame is just a page with a panel with a height of 500px.
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server"></head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" />
<ext:Panel Title="TestGrid" runat="server" ID="Panel1" Height="500">
<Body>
<ext:Label runat="server" ID="Label1" Html="Height: 500px"></ext:Label>
</Body>
</ext:Panel>
</form>
</body>
</html>