Jan 25, 2013, 12:29 PM
[CLOSED] Portlet Close event fires only one times
Hi,
I have problems with the migration from a page with portlets to move from ext.net 1.5 to ext.net 2.1.
On my page I have a grid with two rows and two portlets.
If the grid has entries the portlets are hidden.
By clicking in the gridrow the portlet will be show.
On the other side by closing a portlet the grid has an additional row.
Once it works fine, but If I close the second portlet nothing happens. The event will .not fired.
I have made a sample applikation, which will illustrate it.
I hope you can help me.
Elke
I have problems with the migration from a page with portlets to move from ext.net 1.5 to ext.net 2.1.
On my page I have a grid with two rows and two portlets.
If the grid has entries the portlets are hidden.
By clicking in the gridrow the portlet will be show.
On the other side by closing a portlet the grid has an additional row.
Once it works fine, but If I close the second portlet nothing happens. The event will .not fired.
I have made a sample applikation, which will illustrate it.
I hope you can help me.
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Dashboard.aspx.vb" Inherits="TestApplikation.Dashboard" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Ext.Net.Utilities" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<script runat="server">
Public Class PortletItem
Public PortletDashboard As String
Public PortletId As String
Public PortletName As String
Public PortletIcon As String
Public PortletIsHidden As Boolean
End Class
Private table As DataTable
Private reader As Ext.Net.Model = Nothing
'Private portletItems As List(Of PortletItem)
Private portlets As List(Of PortletItem) = Nothing
Public Sub RefreshTree(portlets As List(Of PortletItem))
Me.DashboardGrid.Store.Clear()
Me.DashboardGrid.Store.Add(CreateStore(GridReader))
Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
table = Nothing
st.DataSource = FillTable(DashboardTable, portlets)
st.DataBind()
End Sub
Private ReadOnly Property PortletList As List(Of PortletItem)
Get
If portlets Is Nothing Then
portlets = New List(Of PortletItem)
Dim pi As New PortletItem
pi.PortletDashboard = "Dashboard"
pi.PortletId = "ptPermit"
pi.PortletIcon = "Lock"
pi.PortletName = "permit"
pi.PortletIsHidden = False
portlets.Add(pi)
pi = New PortletItem
pi.PortletDashboard = "Dashboard"
pi.PortletId = "ptEvent"
pi.PortletIcon = "LightningAdd"
pi.PortletName = "Eevent"
pi.PortletIsHidden = false
portlets.Add(pi)
End If
Return portlets
End Get
End Property
Public Function CreateStore(Optional reader As Ext.Net.Model = Nothing) As Ext.Net.Store
Dim st As New Ext.Net.Store
st.ID = "DashboardStore"
If Not IsNothing(reader) Then
st.Model.Add(reader)
End If
st.GroupField = "PortletDashboard"
Return st
End Function
Public ReadOnly Property GridReader As Ext.Net.Model
Get
If reader Is Nothing Then
reader = New Ext.Net.Model
reader.Fields.Add(New Ext.Net.ModelField("PortletDashboard"))
reader.Fields.Add(New Ext.Net.ModelField("PortletId"))
reader.Fields.Add(New Ext.Net.ModelField("PortletName"))
reader.Fields.Add(New Ext.Net.ModelField("PortleIcon"))
End If
Return reader
End Get
End Property
Private ReadOnly Property DashboardTable As DataTable
Get
If table Is Nothing Then
table = New DataTable
table.Columns.Add("PortletDashboard", GetType(System.String))
table.Columns.Add("PortletId", GetType(System.String))
table.Columns.Add("PortletName", GetType(System.String))
table.Columns.Add("PortleIcon", GetType(System.String))
End If
Return table
End Get
End Property
Private Function FillTable(table As DataTable, list As List(Of PortletItem)) As DataTable
For Each pi In list
If pi.PortletIsHidden = True Then
Dim datarow As DataRow = table.NewRow()
datarow.SetField(Of String)("PortletDashboard", pi.PortletDashboard)
datarow.SetField(Of String)("PortletId", pi.PortletId)
datarow.SetField(Of String)("PortletName", pi.PortletName)
datarow.SetField(Of String)("PortleIcon", pi.PortletIcon)
table.Rows.Add(datarow)
End If
Next
Return table
End Function
<DirectMethod()>
Public Sub SelectPortlet(ByVal sender As Object, ByVal e As DirectEventArgs)
Dim portletId = e.ExtraParams("PortletId")
Dim res = (From a In portlets Where a.PortletId = portletId).Single
portlets.Remove(res)
res.PortletIsHidden = False
portlets.Add(res)
Me.DashboardGrid.Store.Clear()
Me.DashboardGrid.Store.Add(CreateStore(GridReader))
Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
table = Nothing
st.DataSource = FillTable(DashboardTable, portlets)
st.DataBind()
ChangePortlet_Event(portlets)
End Sub
Private Sub ChangePortlet_Event(portl As List(Of PortletItem))
Dim pl As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
portlets = portl
For Each p In pl
Dim pi As PortletItem = (From a In portl Where a.PortletId = p.ID Select a).SingleOrDefault
If pi.PortletIsHidden <> p.Hidden Then
p.Hidden = pi.PortletIsHidden
End If
Next
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Me.DashboardGrid.Store.Add(CreateStore(GridReader))
Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
st.DataSource = FillTable(DashboardTable, PortletList)
st.DataBind()
Dim portletControls As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
For Each control In portletControls
control.CloseAction = CloseAction.Hide
control.DirectEvents.Hide.EventMask.ShowMask = True
control.DirectEvents.Hide.EventMask.Msg = "Saving..."
control.DirectEvents.Hide.EventMask.MinDelay = 500
control.DirectEvents.Hide.ExtraParams.Add(New Ext.Net.Parameter("ID", control.ClientID))
If Not ExtNet.IsAjaxRequest Then
If control.ID.Contains("Permit") Then
Dim pi As PortletItem = (From a In portlets Where a.PortletId = control.ID Select a).SingleOrDefault
control.Hidden = pi.PortletIsHidden
AddHandler control.DirectEvents.Hide.Event, AddressOf Portlet_Hide_Event
ElseIf control.ID.Contains("Event") Then
Dim pi As PortletItem = (From a In portlets Where a.PortletId = control.ID Select a).SingleOrDefault
control.Hidden = pi.PortletIsHidden
AddHandler control.DirectEvents.Hide.Event, AddressOf Portlet_Hide_Event
End If
Else
AddHandler control.DirectEvents.Hide.Event, AddressOf Portlet_Hide_Event
End If
Next
End Sub
Protected Sub Portlet_Hide_Event(sender As Object, e As DirectEventArgs)
Ext.Net.X.Msg.Alert("Status", e.ExtraParams("ID") + " Hidden").Show()
Dim id As String = e.ExtraParams("ID")
Dim ids() As String = id.Split(CChar("."))
Dim pi As PortletItem = (From a In portlets Where a.PortletId = ids(1) Select a).SingleOrDefault
pi.PortletIsHidden = True
RefreshTree(portlets)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Viewport ID="Viewport1" runat="server" layout="BorderLayout">
<Items>
<ext:Panel ID="Tab1" runat="server" Title="Internet" Icon="Vcard" BodyStyle="background-color: transparent;"
Region="Center" Width="300" >
<Items>
<ext:Portal ID="Portal1" runat="server" Border="false" BodyStyle="background-color: transparent;"
Layout="Column">
<Items>
<ext:PortalColumn ID="PortalColumn1" runat="server" StyleSpec="padding:10px 0 10px 10px"
ColumnWidth=".5" Layout="Anchor">
<Items>
</Items>
</ext:PortalColumn>
<ext:PortalColumn ID="PortalColumn2" runat="server" StyleSpec="padding:10px 0 10px 10px"
ColumnWidth=".5" Layout="Anchor">
<Items>
<ext:Portlet ID="ptPermit" runat="server" Title="Permit" />
<ext:Portlet ID="ptEvent" Title="Event" runat="server">
</ext:Portlet>
</Items>
</ext:PortalColumn>
</Items>
</ext:Portal>
</Items>
</ext:Panel>
<ext:Panel runat="server" Title="Settings" Width="180" ID="Panel1" Layout="FitLayout" Region="West" MinWidth="175" MaxWidth="1740" Html="asdfg" BodyStyle="background-color: red;">
<Items>
<ext:GridPanel ID="DashboardGrid" runat="server"
Border="false" HideHeaders="True">
<ColumnModel>
<Columns>
<ext:Column runat="server" ID="colDashboard" DataIndex="PortletDashboard" Width="0"
Hidden="true" Groupable="False" Sortable="False" MenuDisabled="False" />
<ext:Column runat="server" ID="colId" DataIndex="PortletId" Width="20" Hidden="true"
Groupable="False" Sortable="False" MenuDisabled="False" />
<ext:Column runat="server" ID="colPortletName" DataIndex="PortletName" Width="200"
Hidden="false" Groupable="False" Sortable="False" MenuDisabled="False" />
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Simple">
<DirectEvents>
<Select OnEvent="SelectPortlet">
<EventMask ShowMask="true" />
<ExtraParams>
<ext:Parameter Name="PortletId" Value="record.data.PortletId" Mode="Raw" />
</ExtraParams>
</Select>
</DirectEvents>
</ext:RowSelectionModel>
</SelectionModel>
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</form>
</body>
</html>
mfgElke
Last edited by Daniil; Jan 31, 2013 at 8:20 AM.
Reason: [CLOSED]