[CLOSED] Portlet Close event fires only one times

  1. #1

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

    <%@ 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>
    mfg
    Elke
    Last edited by Daniil; Jan 31, 2013 at 9:20 AM. Reason: [CLOSED]
  2. #2
    Hi Peter,

    Please move
    control.CloseAction = CloseAction.Hide
    inside this If statement.
    If Not ExtNet.IsAjaxRequest Then
    I would move these things as well.
    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))
    I think there is no need to execute it each request.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi Peter,

    Please move
    control.CloseAction = CloseAction.Hide
    inside this If statement.
    If Not ExtNet.IsAjaxRequest Then
    I would move these things as well.
    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))
    I think there is no need to execute it each request.


    Hi Danii,

    Tanks ,
    this side works now.
    But the other side, I have the grid with the portlet entries and I want set the portlet to hidden = false..
    In my sample application it doesn't work.
    And the next problem is the expand control and unexpand control button.
    If I expand the control on the top the second control will be expanded.

    Modiefied Code.
    <%@ 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" %>
    <%@ Register TagPrefix="ucPermitGrid" TagName="PermitGrid" Src="~/TestUserControl.ascx" %>
    <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 s
      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
                ' p.Hidden = pi.PortletIsHidden
                s += p.ID + "   " + p.Hidden.ToString() + "   "
            Next
            
            Ext.Net.X.Msg.Alert("Status", s).Show()
     End Sub
     
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            
            If Not ExtNet.IsAjaxRequest And Not IsPostBack Then
                portlets = PortletList
                Session("Portlets") = portlets
            Else
                portlets = CType(Session("Portlets"), Global.System.Collections.Generic.List(Of PortletItem))
            End If
            Me.DashboardGrid.Store.Add(CreateStore(GridReader))
            Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
            st.DataSource = FillTable(DashboardTable, portlets)
            st.DataBind()
            Dim portletControls As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
            For Each control In portletControls
    
                
                If Not ExtNet.IsAjaxRequest Then
                    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 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" >
                                            <Content>
                                                  <ucPermitGrid:PermitGrid ID="PermitGrid2" runat="server" />
                                            </Content>
                                        </ext:Portlet>
                                        <ext:Portlet ID="ptEvent" Title="Event" runat="server" >
                                            <Content>
                                                  <ucPermitGrid:PermitGrid ID="PermitGrid1" runat="server" />
                                            </Content>
                                        </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>

    and the UserControl


    [<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="TestUserControl.ascx.vb" Inherits="TestApplikation.TestUserControl" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
     <ext:Container ID="Container1" runat="server">
        <Content>
            <asp:Label ID="Label1" runat="server" Text="I am ASP.NET Label" />
        </Content>
    </ext:Container>

    Hope you can help me.

    Kind regardes
    Elke
    Last edited by Daniil; Jan 29, 2013 at 3:18 PM. Reason: Corrected the [/CODE] tag
  4. #4
    Quote Originally Posted by sisa View Post
    But the other side, I have the grid with the portlet entries and I want set the portlet to hidden = false..
    In my sample application it doesn't work.
    Where do you do that? During initial Page_Load or an AJAX request? If the second, what are the steps to reproduce?

    The sample is a bit complicated. I guess it could be quite simplified.

    Quote Originally Posted by sisa View Post
    And the next problem is the expand control and unexpand control button.
    If I expand the control on the top the second control will be expanded.
    It is a layout issue. The portlets are initially expanded. To fix this issue I can recommend to set up Layout="FitLayout" for the Portlets.
  5. #5
    Quote Originally Posted by Daniil View Post
    Where do you do that? During initial Page_Load or an AJAX request? If the second, what are the steps to reproduce?

    The sample is a bit complicated. I guess it could be quite simplified.



    It is a layout issue. The portlets are initially expanded. To fix this issue I can recommend to set up Layout="FitLayout" for the Portlets.




    Hi Daniel,
    Layout=FitLayout works, now the portlets expand/collapse correctly.
    But the other problem is still available.
    I have tried to simplify but then it is not possible to show you the problem.
    The screen should give the user the possibility to open the portlets by clicking in the grid and closing the portlets by the hide button. At the moment it works one times. and if I do it second times it doesn't shows the portlet.
    I have set an messagebox alert inside the code from the function "ChangePortlet_Event" to show you the problem. At this point the portlet will be set to hidden = false.

    But you must open the portlet, close the portlet and then it will happens.


    <%@ 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" %>
    <%@ Register TagPrefix="ucPermitGrid" TagName="PermitGrid" Src="~/TestUserControl.ascx" %>
    <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 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 = True
        portlets.Add(pi)
        pi = New PortletItem
        pi.PortletDashboard = "Dashboard"
        pi.PortletId = "ptEvent"
        pi.PortletIcon = "LightningAdd"
        pi.PortletName = "Eevent"
                    pi.PortletIsHidden = True
        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, portletId)
        End Sub
     
        Private Sub ChangePortlet_Event(portl As List(Of PortletItem), name As String)
            Dim pl As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
            portlets = portl
            For Each p In pl
                If p.ID.Contains(name) Then
                     Ext.Net.X.Msg.Alert("Status", name + " " + p.Hidden.ToString).Show()
                    p.Hidden = False
                End If
              
            Next
        End Sub
     
     
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            
            If Not ExtNet.IsAjaxRequest And Not IsPostBack Then
                portlets = PortletList
                Session("Portlets") = portlets
            Else
                portlets = CType(Session("Portlets"), Global.System.Collections.Generic.List(Of PortletItem))
            End If
            Me.DashboardGrid.Store.Add(CreateStore(GridReader))
            Dim st As Ext.Net.Store = Me.DashboardGrid.GetStore()
            st.DataSource = FillTable(DashboardTable, portlets)
            st.DataBind()
            Dim portletControls As List(Of Portlet) = ControlUtils.FindControls(Of Portlet)(Me.Page)
            For Each control In portletControls
    
                
                If Not ExtNet.IsAjaxRequest Then
                    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 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)
           
            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" layout="FitLayout" >
                                            <Content>
                                                  <ucPermitGrid:PermitGrid ID="PermitGrid2" runat="server" />
                                            </Content>
                                        </ext:Portlet>
                                        <ext:Portlet ID="ptEvent" Title="Event" runat="server" Layout="FitLayout" >
                                            <Content>
                                                  <ucPermitGrid:PermitGrid ID="PermitGrid1" runat="server" />
                                            </Content>
                                        </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" ButtonAlign="Left">
                            
                <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>

    It happens inside an <DirectMethod()>.

    hope you can help me
    Elke
  6. #6
    Using this technique:
    How to prepare a sample

    I was able to simplify the example to the below one, but it still reproduces the issue. Please use this technique in the future.

    Steps:

    1. Close the both Portlets clicking the X tool.
    2. Click the Button.

    I think the portlets should appear and it is a bug.

    Interesting that if call the Portlets' hide method, then click the Show Button - the Portlets appear.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <ext:Button 
            runat="server" 
            Text="Show" 
            Handler="App.Portlet1.show(); 
                     App.Portlet2.show();" />
    
            <ext:Portal 
                ID="Portal1" 
                runat="server" 
                Width="300" 
                Height="300">
                <Items>
                    <ext:PortalColumn runat="server">
                        <Items>
                            <ext:Portlet 
                                ID="Portlet1" 
                                runat="server" 
                                Html="Portlet 1" 
                                CloseAction="Hide" />
    
                            <ext:Portlet 
                                ID="Portlet2" 
                                runat="server" 
                                Html="Portlet 2" 
                                CloseAction="Hide" />
                        </Items>
                    </ext:PortalColumn>
                </Items>
            </ext:Portal>
    </body>
    </html>
  7. #7
    It has been fixed in SVN trunk. It will be publicly available with the next release. Thank you for the bug report.
  8. #8
    Quote Originally Posted by Daniil View Post
    Using this technique:
    How to prepare a sample

    I was able to simplify the example to the below one, but it still reproduces the issue. Please use this technique in the future.

    Steps:

    1. Close the both Portlets clicking the X tool.
    2. Click the Button.

    I think the portlets should appear and it is a bug.

    Interesting that if call the Portlets' hide method, then click the Show Button - the Portlets appear.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
        
        <ext:Button 
            runat="server" 
            Text="Show" 
            Handler="App.Portlet1.show(); 
                     App.Portlet2.show();" />
    
            <ext:Portal 
                ID="Portal1" 
                runat="server" 
                Width="300" 
                Height="300">
                <Items>
                    <ext:PortalColumn runat="server">
                        <Items>
                            <ext:Portlet 
                                ID="Portlet1" 
                                runat="server" 
                                Html="Portlet 1" 
                                CloseAction="Hide" />
    
                            <ext:Portlet 
                                ID="Portlet2" 
                                runat="server" 
                                Html="Portlet 2" 
                                CloseAction="Hide" />
                        </Items>
                    </ext:PortalColumn>
                </Items>
            </ext:Portal>
    </body>
    </html>


    Thanks,
    Elke

Similar Threads

  1. [CLOSED] Portlet Close Handler
    By gs_user in forum 2.x Premium Help
    Replies: 1
    Last Post: Aug 15, 2012, 11:37 AM
  2. [CLOSED] GridPanel RowSelect event fires twice
    By vadym.f in forum 1.x Premium Help
    Replies: 4
    Last Post: Jul 17, 2012, 2:30 PM
  3. [1.0] Portlet - Hide close button
    By serdias in forum 1.x Help
    Replies: 2
    Last Post: Nov 16, 2010, 11:10 PM
  4. [CLOSED] Add close (hide) tool button and event to Portlet
    By betamax in forum 1.x Premium Help
    Replies: 2
    Last Post: Oct 01, 2010, 2:16 PM
  5. [CLOSED] [1.0] SelectBox Select event fires twice
    By randy85253 in forum 1.x Premium Help
    Replies: 1
    Last Post: Dec 09, 2009, 3:20 PM

Posting Permissions