[CLOSED] Problem with portal and portlets

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Problem with portal and portlets

    There is a portal in my website, in which i add PortalColumns dynamically (to the "Items" property). To these PortalColumns Items i add Portlets, also dynamically. The portlets use autoload with LoadMode.IFrame to load urls into them. There is a window with fields the user can use to add or remove new items from the screen (portlets), choosing the url, title, etc and then clicking an "add" button. When the user adds a new item, i call a method in which i clear the portal's items and re-add them with the newly added one: there is a db table in which i record user's items. I call portal.Items.Clear(), then read the table and re-add them.

    The first problem is that this never updates the items in the screen. The only way to get the items updated is to do a postback.
    The second one is that if user adds more than 3 items (2 portal columns with 4 portlets), he gets an erros saying that 'System.Collections.ArrayList' can't be converted to 'System.Web.UI.Pair' in Ext.Net's ViewState.cs.

    If i do a postback the portlet is loaded normally.
    I've seen a few posts that seemed to be related to the second problem, and tried the solutions provided, but none seemed to work (like calling DoLayout(), using unique ids, etc).

    Please, see if you can help me.
  2. #2
    Hello!

    Thanks a lot for detailed description of your problem. But providing us with a sample code reproducing the issue would be much better. Could you provide?
    Last edited by Daniil; Aug 13, 2010 at 8:46 AM.
  3. #3
    Sure, there it its:

        private void LoadPortlets()
        {
            ...
            
            portal.Items.Clear();
            
            DataTable dataTable = LoadDataTableWithRegisteredPortlets();
            Int32 i = 0;
            for (; i < dataTable.Rows.Count; i += 2)
            {
                Portlet portlet1 = CreatePortLet(dataTable.Rows[i]["TITLE"].ToString(), dataTable.Rows[i]["URL"].ToString());
                Portlet portlet2 = null;
                if ((i + 1) < dataTable.Rows.Count)
                {
                    portlet2 = CreatePortLet(dataTable.Rows[i + 1]["TITLE"].ToString(), dataTable.Rows[i + 1]["URL"].ToString());
                }
                portal.Items.Add(CreateportalColumn(portlet1, portlet2));
            }
    
            ...
    
        }
    
    private Portlet CreatePortLet(String title, String url)
        {
            Portlet portlet = new Portlet();
            portlet.Title = title;
            portlet.AutoHeight = true;
            portlet.Frame = true;
            portlet.AutoLoad.Url = url;
            portlet.AutoLoad.ShowMask = true;
            portlet.AutoLoad.Mode = LoadMode.IFrame;
            portlet.AutoLoad.MaskMsg = "Loading" + title + "...";
    
            return portlet;
        }
        
        private PortalColumn CreateportalColumn(Portlet item1, Portlet item2)
        {
            PortalColumn portalColumn = new PortalColumn()
            {
                Layout = "Anchor",
                AutoHeight = true,
                StyleSpec = "padding:5px 0 5px 5px",
                ColumnWidth = 0.33
            };
    
            portalColumn.Items.Add(item1);
            if (item2 != null)
                portalColumn.Items.Add(item2);
            return portalColumn;
        }
    in page_load and whenever user creates a new portlet (button click direct event), i call LoadPortlets().
    Last edited by geoffrey.mcgill; Aug 12, 2010 at 10:28 PM. Reason: please use [CODE] tags
  4. #4
    So, Daniil... Any hint? I'm really needing some help with this.
  5. #5
    Hi,

    During DirectEvent you have to use special methods to render new controls: Render, AddTo, InsertTo
    Please see the following sample which demonstrates how to add portlets (see Top toolbar buttons)
    <%@ Page Language="C#" %>
    <%@ Import Namespace="Ext.Net.Utilities" %>
    <%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                string text = @"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.";
    
                this.ResourceManager1.RegisterClientScriptBlock("text", string.Format("var text=\"{0}\";", text));
    
                foreach (Portlet portlet in ControlUtils.FindControls<Portlet>(this.Page))
                {
                    portlet.Html = "={text}";
                    portlet.Tools.Add(new Tool(ToolType.Close, string.Concat(portlet.ClientID, ".hide();"), "Close Portlet"));
                }
            }
    
            foreach (Portlet portlet in ControlUtils.FindControls<Portlet>(this.Page))
            {
                portlet.DirectEvents.Hide.Event += Portlet_Hide;
                portlet.DirectEvents.Hide.EventMask.ShowMask = true;
                portlet.DirectEvents.Hide.EventMask.Msg = "Saving...";
                portlet.DirectEvents.Hide.EventMask.MinDelay = 500;
                
                portlet.DirectEvents.Hide.ExtraParams.Add(new Ext.Net.Parameter("ID", portlet.ClientID));
            }
        }
    
        protected void Portlet_Hide(object sender, DirectEventArgs e)
        {
           X.Msg.Alert("Status", e.ExtraParams["ID"] + " Hidden").Show();
        }
    
        protected void AddColumn1(object sender, DirectEventArgs e)
        {
            Portlet p = new Portlet { 
                Title = "New portlet in column1",
                Html = DateTime.Now.ToShortTimeString()
            };
    
            //must be called during DirectEvent only (if X.IsAjaxRequest == true)
            p.AddTo(Portal1_Column1);
        }
    
        protected void AddColumn2(object sender, DirectEventArgs e)
        {
            Portlet p = new Portlet
            {
                Title = "New portlet in column2",
                Html = DateTime.Now.ToShortTimeString()
            };
    
            //must be called during DirectEvent only (if X.IsAjaxRequest == true)
            p.InsertTo(0, Portal1_Column2);
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Portal in TabPanel - Ext.NET Examples</title>
        <link href="../../../../resources/css/examples.css" rel="stylesheet" type="text/css" /> 
        
        <style type="text/css">
            .x-column-padding{
                padding: 10px 0px 10px 10px;
            }
            
            .x-column-padding1{
                padding: 10px;
            }
        </style>  
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server" />
            
            <ext:Viewport runat="server">
                <Items>
                    <ext:BorderLayout runat="server">
                        <West 
                            Collapsible="true" 
                            Split="true" 
                            MinWidth="175" 
                            MaxWidth="400" 
                            MarginsSummary="5 0 5 5" 
                            CMarginsSummary="5 5 5 5">
                            <ext:Panel runat="server" Title="West" Width="200">
                                <Items>
                                    <ext:AccordionLayout runat="server" Animate="true">
                                        <Items>
                                            <ext:Panel 
                                                runat="server" 
                                                Border="false" 
                                                Collapsed="true" 
                                                Icon="Note"
                                                AutoScroll="true"
                                                Title="Content"
                                                Html="={text}"
                                                Padding="5"
                                                />
                                            <ext:Panel
                                                runat="server" 
                                                Border="false" 
                                                Collapsed="true" 
                                                Icon="FolderWrench" 
                                                AutoScroll="true"
                                                Title="Settings"
                                                Html="={text}"
                                                Padding="5"
                                                />
                                        </Items>
                                    </ext:AccordionLayout>
                                </Items>
                            </ext:Panel>
                        </West>
                        <Center MarginsSummary="5 5 5 0">
                            <ext:TabPanel runat="server" ActiveTabIndex="0" Title="TabPanel">
                                <Items>
                                    <ext:Panel runat="server" Title="Tab 1" Layout="Fit">
                                        <TopBar>
                                            <ext:Toolbar runat="server">
                                                <Items>
                                                    <ext:Button runat="server" Text="Add to end of the first column">
                                                        <DirectEvents>
                                                            <Click OnEvent="AddColumn1" />
                                                        </DirectEvents>
                                                    </ext:Button>
                                                    
                                                    <ext:Button runat="server" Text="Add to begin of the second column">
                                                        <DirectEvents>
                                                            <Click OnEvent="AddColumn2" />
                                                        </DirectEvents>
                                                    </ext:Button>
                                                </Items>
                                            </ext:Toolbar>
                                        </TopBar>
                                        <Items>
                                            <ext:Portal runat="server" Border="false" Layout="Column">
                                                <Items>
                                                    <ext:PortalColumn 
                                                        ID="Portal1_Column1"
                                                        runat="server" 
                                                        Cls="x-column-padding"
                                                        ColumnWidth=".33"
                                                        Layout="Anchor">
                                                        <Items>
                                                            <ext:Portlet ID="Portlet1" runat="server" Title="Another Panel 1" />
                                                        </Items>
                                                    </ext:PortalColumn>
                                                    <ext:PortalColumn 
                                                        ID="Portal1_Column2"
                                                        runat="server" 
                                                        Cls="x-column-padding"
                                                        ColumnWidth=".33"
                                                        Layout="Anchor">
                                                        <Items>
                                                            <ext:Portlet ID="Portlet2" runat="server" Title="Panel 2" />
                                                            <ext:Portlet ID="Portlet3" runat="server" Title="Another Panel 2" />
                                                        </Items>
                                                    </ext:PortalColumn>
                                                    <ext:PortalColumn 
                                                        runat="server" 
                                                        Cls="x-column-padding1"
                                                        ColumnWidth=".33"
                                                        Layout="Anchor">
                                                        <Items>
                                                            <ext:Portlet ID="Portlet4" runat="server" Title="Panel 3" />
                                                            <ext:Portlet ID="Portlet5" runat="server" Title="Another Panel 3" />
                                                        </Items>
                                                    </ext:PortalColumn>
                                                </Items>
                                            </ext:Portal>
                                        </Items>
                                    </ext:Panel>
                                    <ext:Panel runat="server" Title="Tab 2" Layout="Fit">
                                        <Items>
                                            <ext:Portal runat="server" Border="false" Layout="Column">
                                                <Items>
                                                    <ext:PortalColumn 
                                                        runat="server" 
                                                        Cls="x-column-padding"
                                                        ColumnWidth=".33"
                                                        Layout="Anchor">
                                                        <Items>
                                                            <ext:Portlet ID="Portlet6" Title="Panel 3" runat="server" />
                                                            <ext:Portlet ID="Portlet7" Title="Another Panel 3" runat="server" />
                                                        </Items>
                                                    </ext:PortalColumn>
                                                    <ext:PortalColumn 
                                                        runat="server" 
                                                        Cls="x-column-padding"
                                                        ColumnWidth=".33"
                                                        Layout="Anchor">
                                                        <Items>
                                                            <ext:Portlet ID="Portlet8" Title="Panel 2" runat="server" />
                                                            <ext:Portlet ID="Portlet9" Title="Another Panel 2" runat="server" />
                                                        </Items>
                                                    </ext:PortalColumn>
                                                    <ext:PortalColumn 
                                                        runat="server" 
                                                        Cls="x-column-padding1"
                                                        ColumnWidth=".33"
                                                        Layout="Anchor">
                                                        <Items>
                                                            <ext:Portlet ID="Portlet10" Title="Another Panel 1" runat="server" />
                                                        </Items>
                                                    </ext:PortalColumn>
                                                </Items>
                                            </ext:Portal>  
                                        </Items>                                  
                                    </ext:Panel>
                                </Items>
                            </ext:TabPanel> 
                        </Center>
                    </ext:BorderLayout>
                </Items>
            </ext:Viewport>
        </form>
    </body>
    </html>
    Vladimir Shcheglov
    Sr. Developer
  6. #6
    Ok, i'm beginning to figure it out. Now i can add the items, but:

    i want to have 3 columns with 2 portlets each. Then, if i try to clear them all and re-add the items, they won't get cleared, don't know why, and i'll end up with duplicate portlets (is there a similar ajaxrequest only method for clearing them?). I also can't add only the portlet that the user is inserting, because the item count of the columns is always 0, so the portlet will always be added to the first column, and as i can't read the already added portlets i can't validate if he is entering a duplicate portlet either.

    Any hint?
  7. #7
    Hi,
    Then, if i try to clear them all and re-add the items, they won't get cleared, don't know why
    Please call RemoveAll method for the portal to remove all portlets (please note that RemoveAll doesn't modify Items collection on the server side, it just generates script to remove all items on the client side)
    Portal1.RemoveAll();
    I also can't add only the portlet that the user is inserting, because the item count of the columns is always 0, so the portlet will always be added to the first column
    ASP.NET is stateless system therefore if you add portlets and columns dynamically (via code behind) then you have to recreate all of those controls on each request (if you need to handle portlets on the server side)
    Otherwise you can use id (if you know it or you can pass that id from client side)
    p.AddTo("Portal1_Column1");
    Vladimir Shcheglov
    Sr. Developer
  8. #8
    RemoveAll() worked to clear the portlets from the columns, so i just have to re-add them all.
    Now there is one more problem, i think it's a bug or something...

    If call RemoveAll() (i call it for each PortalColumn is the portal's items), if i try to show a window after it (the window has nothing to do with the portal where the PortalColumns are, just the button that shows it is on the Buttons section of it) i get a javascript error saying that the object 'WindowAddInformacoes' is null or is not an object (WindowAddInformacoes is the name of my window). The same button shows the window normally if i don't call RemoveAll().

    Here is my aspx (the portal's ID is "telaInformacoes" and the window's is "WindowAddInformacoes") :

    <body>
        <form id="Form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Store ID="Store1" runat="server">
            <Reader>
                <ext:ArrayReader>
                    <Fields>
                        <ext:RecordField Name="fornecedor" />
                        <ext:RecordField Name="notitulo" />
                        <ext:RecordField Name="valortitulo" Type="Float" />
                        <ext:RecordField Name="valoratual" Type="Float" />
                        <ext:RecordField Name="vencimento" Type="Date" />
                        <ext:RecordField Name="dias" Type="Float" />
                    </Fields>
                </ext:ArrayReader>
            </Reader>
        </ext:Store>
        <ext:Viewport ID="Viewport1" runat="server" Layout="Fit">
            <Items>
                <ext:BorderLayout ID="BorderLayout1" runat="server">
                    <Center>
                        <ext:GroupTabPanel ID="GroupTabPanel1" runat="server" TabWidth="110" ActiveGroupIndex="0">
                            <Groups>
                                <ext:GroupTab ID="Group1" runat="server" MainItem="0">
                                    <Items>
                                        <ext:Portal ID="telaInformacoes" runat="server" Title="Informações" TabTip="Janela de Informações"
                                            Layout="Column" ButtonAlign="Center">
                                            <Buttons>
                                                <ext:Button ID="btnAddinformacoes" runat="server" Icon="Add" Text="Adicionar...">
                                                    <Listeners>
                                                        <Click Handler="#{WindowAddInformacoes}.show(this);" />
                                                    </Listeners>
                                                </ext:Button>
                                                <ext:Button ID="btnDeleteInformacoes" runat="server" Icon="Delete" Text="Remover...">
                                                </ext:Button>
                                                <%--                                          </Items>
                                                </ext:StatusBar>--%>
                                            </Buttons>
                                            <Items>
                                                <ext:PortalColumn ID="informacoesColumn1" runat="server" Cls="x-column-padding" ColumnWidth=".33"
                                                    Layout="Anchor">
                                                </ext:PortalColumn>
                                                <ext:PortalColumn ID="informacoesColumn2" runat="server" Cls="x-column-padding" ColumnWidth=".33"
                                                    Layout="Anchor">
                                                </ext:PortalColumn>
                                                <ext:PortalColumn ID="informacoesColumn3" runat="server" Cls="x-column-padding" ColumnWidth=".33"
                                                    Layout="Anchor">
                                                </ext:PortalColumn>
                                            </Items>
                                        </ext:Portal>
                                        <ext:Panel ID="Panel4" runat="server" Title="Favoritos" Icon="StarGold" TabTip="Lista as aplicações favoritas selecionadas pelo usuário"
                                            StyleSpec="padding: 5px;" ButtonAlign="Center">
                                            <Buttons>
                                                <ext:Button runat="server" ID="btnAjuda" Icon="Help" Text="Ajuda">
                                                </ext:Button>
                                            </Buttons>
                                            <AutoLoad Url="Favourites.aspx" ShowMask="true" Mode="iframe" MaskMsg="Carregando Favoritos..." />
                                        </ext:Panel>
                                        <ext:Portal ID="telaConsultas" runat="server" Title="Consultas" TabTip="Janela de Consultas"
                                            Icon="DatabaseGear" Layout="Row">
                                            <Items>
                                            </Items>
                                        </ext:Portal>
                                        <ext:Panel ID="Panel2" runat="server" Title="Tarefas" Icon="ClockEdit" TabTip="Tarefas"
                                            StyleSpec="padding: 10px;" Layout="Fit">
                                            <Items>
                                                <ext:GridPanel ID="gvTarefas" runat="server" StripeRows="true" TrackMouseOver="true"
                                                    Border="true" ButtonAlign="Center">
                                                    <Buttons>
                                                        <ext:Button runat="server" ID="btAdicionarTarefa" Icon="Add" Text="Adicionar tarefa...">
                                                            <Listeners>
                                                                <Click Handler="#{windowAddTarefa}.show(this);" />
                                                            </Listeners>
                                                        </ext:Button>
                                                    </Buttons>
                                                    <Store>
                                                        <ext:Store ID="gvTarefasStore" runat="server" GroupField="DATA">
                                                            <Reader>
                                                                <ext:JsonReader>
                                                                    <Fields>
                                                                        <ext:RecordField Name="MTR_CODIGO" Type="String" />
                                                                        <ext:RecordField Name="DATA" Type="String" />
                                                                        <ext:RecordField Name="DATAPOREXTENSO" Type="String" />
                                                                        <ext:RecordField Name="HORA" Type="String" />
                                                                        <ext:RecordField Name="DESCRICAO" Type="String" />
                                                                        <ext:RecordField Name="AVISADO" Type="String" />
                                                                    </Fields>
                                                                </ext:JsonReader>
                                                            </Reader>
                                                        </ext:Store>
                                                    </Store>
                                                    <View>
                                                        <ext:GroupingView ID="GroupingView1" HideGroupedColumn="true" runat="server" ForceFit="true"
                                                            StartCollapsed="true" GroupTextTpl='<span id="ColorCode-{[values.rs[0].data.ColorCode]}"></span>{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Tarefas" : "Tarefa"]})'
                                                            EnableRowBody="true">
                                                        </ext:GroupingView>
                                                    </View>
                                                    <ColumnModel ID="ColumnModel3" runat="server">
                                                        <Columns>
                                                            <ext:CommandColumn Width="17">
                                                                <Commands>
                                                                    <ext:GridCommand Icon="Delete" CommandName="Remover">
                                                                        <ToolTip Text="Remover..." />
                                                                    </ext:GridCommand>
                                                                </Commands>
                                                            </ext:CommandColumn>
                                                            <ext:Column Header="Data" DataIndex="DATA" />
                                                            <ext:Column Header="Hora" DataIndex="HORA" Width="40px" />
                                                            <ext:Column Header="Tarefa" DataIndex="DESCRICAO" Width="500px" />
                                                        </Columns>
                                                    </ColumnModel>
                                                    <DirectEvents>
                                                        <Command>
                                                            <EventMask ShowMask="true" />
                                                            <ExtraParams>
                                                                <ext:Parameter Name="command" Value="command" Mode="Raw" />
                                                                <ext:Parameter Name="codigo" Value="record.data.MTR_CODIGO" Mode="Raw" />
                                                            </ExtraParams>
                                                        </Command>
                                                    </DirectEvents>
                                                </ext:GridPanel>
                                            </Items>
                                        </ext:Panel>
                                    </Items>
                                </ext:GroupTab>
                            </Groups>
                        </ext:GroupTabPanel>
                    </Center>
                </ext:BorderLayout>
            </Items>
        </ext:Viewport>
        <ext:Window Padding="3" Modal="true" Height="120px" Width="300px" runat="server"
            Hidden="true" ID="WindowAddInformacoes" Title="Adicionar Informações" ButtonAlign="Center">
            <Items>
                <ext:TextField runat="server" LabelWidth="50" Width="280" ID="tbAddInfoTitulo" FieldLabel="Título" />
                <ext:TextField runat="server" LabelWidth="50" Width="280" ID="tbAddInfoUrl" FieldLabel="Url" />
            </Items>
            <BottomBar>
                <ext:Toolbar runat="server">
                    <Items>
                        <ext:Button Icon="Add" Text="Inserir" ID="btnSaveAddInformacoes" runat="server">
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:Window>
        <ext:Window Padding="3" Modal="true" Height="400px" Width="625px" runat="server"
            Hidden="true" ID="windowDeleteInformacoes" Title="Remover Informações" ButtonAlign="Center"
            Layout="Fit">
            <Items>
                <ext:GridPanel ID="gvDeleteInformacoes" runat="server" StripeRows="true" TrackMouseOver="true"
                    Title="Tarefas" Border="false">
                    <Store>
                        <ext:Store ID="gvDeleteInformacoesStore" runat="server">
                            <Reader>
                                <ext:JsonReader>
                                    <Fields>
                                        <ext:RecordField Name="MRSS_CODIGO" Type="Int" />
                                        <ext:RecordField Name="MRSS_TITULO" Type="String" />
                                        <ext:RecordField Name="MRSS_RSS" Type="String" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                    </Store>
                    <ColumnModel ID="ColumnModel2" runat="server">
                        <Columns>
                            <ext:Column Header="Título" DataIndex="MRSS_TITULO" />
                            <ext:Column Header="Url" DataIndex="MRSS_RSS" Width="500px" />
                        </Columns>
                    </ColumnModel>
                    <DirectEvents>
                        <Command>
                            <EventMask ShowMask="true" />
                            <ExtraParams>
                                <ext:Parameter Name="command" Value="command" Mode="Raw" />
                                <ext:Parameter Name="codigo" Value="record.data.MRSS_CODIGO" Mode="Raw" />
                            </ExtraParams>
                        </Command>
                    </DirectEvents>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="false" />
                    </SelectionModel>
                    <BottomBar>
                        <ext:Toolbar ID="Toolbar2" runat="server">
                            <Items>
                                <ext:Button Icon="Delete" Text="Remover Selecionados" ID="btnDeleteSelectedInformacoes"
                                    runat="server">
                                    <DirectEvents>
                                        <Click>
                                            <ExtraParams>
                                                <ext:Parameter Name="Values" Value="Ext.encode(#{gvDeleteInformacoes}.getRowsValues({selectedOnly:true}))"
                                                    Mode="Raw" />
                                            </ExtraParams>
                                        </Click>
                                    </DirectEvents>
                                </ext:Button>
                            </Items>
                        </ext:Toolbar>
                    </BottomBar>
                </ext:GridPanel>
            </Items>
        </ext:Window>
        <ext:Window Padding="3" Modal="true" Height="170px" Width="300px" runat="server"
            Hidden="true" ID="windowAddTarefa" Title="Adicionar Tarefa" ButtonAlign="Center">
            <Items>
                <ext:TextField runat="server" LabelWidth="50" Width="280" ID="tbDescricaoTarefa"
                    FieldLabel="Tarefa" />
                <ext:DateField runat="server" LabelWidth="50" Width="280" ID="tbDataTarefa" FieldLabel="Data" />
                <ext:TextField runat="server" LabelWidth="50" Width="280" ID="tbHoraTarefa" FieldLabel="Hora" />
                <ext:Checkbox runat="server" LabelWidth="50" ID="cbAvisarTarefa" FieldLabel="Avisar" />
            </Items>
            <BottomBar>
                <ext:Toolbar ID="Toolbar3" runat="server">
                    <Items>
                        <ext:Button Icon="Add" Text="Inserir" ID="btSaveAddTarefa" runat="server">
                        </ext:Button>
                    </Items>
                </ext:Toolbar>
            </BottomBar>
        </ext:Window>
        </form>
    </body>
    </html>
    Last edited by Daniil; Aug 16, 2010 at 12:06 PM. Reason: Please use [code] tags
  9. #9
    Hello!

    I'm trying to reproduce the issue using the code you provided but I can't. I load the .aspx page and invoke the removeAll method on each PortalColumn (I use FireBug console) and the WindowAddInformacoes window is still shown when I click the respective button.

    Could you provide us with a full sample code to reproduce the issue or a scenario to reproduce this one using the code you already provided?
  10. #10
    public partial class Dashdoard : System.Web.UI.Page
    {
        #region SQL
        String QUERY_INFORMACOES = @"
        ";
    
        String QUERY_TAREFAS = @"
            ";
        #endregion
    
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Associação de Eventos
            gvTarefas.DirectEvents.Command.Event += new ComponentDirectEvent.DirectEventHandler(Command_EventRemoveTarefa);
            btnSaveAddInformacoes.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(btnSaveAddInformacoes_Click);
            btnDeleteInformacoes.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_EventShowDeleteInformacoes);
            btnDeleteSelectedInformacoes.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_EventDeleteSelectedInformacoes);
            btSaveAddTarefa.DirectEvents.Click.Event += new ComponentDirectEvent.DirectEventHandler(Click_EventAddTarefa);
            btnAjuda.DirectEvents.Click.Event += new Ext.Net.ComponentDirectEvent.DirectEventHandler(Click_EventAjudaFavoritos);
            #endregion
    
            if (!Page.IsPostBack)
            {
                LoadTarefas();
                LoadInformacoes();
                LoadConsultas();
            }
    
        }
    
        #region Tarefa
        void Click_EventAddTarefa(object sender, DirectEventArgs e)
        {
            String INSERT_TAREFA = ...
            
            if (tbDescricaoTarefa.Text != String.Empty && tbDataTarefa.Value != null && tbHoraTarefa.Value != null)
            {
                MXM.Connection.DBConnection dbConnection = new DBConnection((Session[0] as AmbienteList)[0]);
                DbTransaction dbTransaction = dbConnection.Connection.BeginTransaction();
                try
                {
                    TimeSpan horaAux;
                    if (TimeSpan.TryParse(tbHoraTarefa.Text, out horaAux))
                    {
                        String insert = String.Format(INSERT_TAREFA,
                            (Session[0] as AmbienteList)[0].UserName,
                            tbDescricaoTarefa.Text,
                            String.Format("{0} {1}", Convert.ToDateTime(tbDataTarefa.Value).ToString("dd/MM/yyyy"), tbHoraTarefa.Text
                            ), (cbAvisarTarefa.Checked ? 1 : 0)
                            );
                        dbConnection.ExecuteNonQuery(insert, dbTransaction);
                        dbTransaction.Commit();
                    }
                    else
                    {
                        Notification.Show(new NotificationConfig() { Html = "Formato de hora inválido." });
                    }
                }
                catch (Exception ex)
                {
                    dbTransaction.Rollback();
                    throw ex;
                }
                finally
                {
                    dbConnection.Connection.Close();
                }
                tbDescricaoTarefa.Text = String.Empty;
                tbHoraTarefa.Text = String.Empty;
                tbDataTarefa.Clear();
                cbAvisarTarefa.Checked = false;
                windowAddTarefa.Hide();
                LoadTarefas();
            }
            else
            {
                Notification.Show(new NotificationConfig() { Html = "Todos os campos são obrigatórios" });
            }
        }
        void Command_EventRemoveTarefa(object sender, DirectEventArgs e)
        {
            if (e.ExtraParams["command"] == "Remover")
            {
                String codigo = e.ExtraParams["codigo"];
                MXM.Persistence.Persistence persist = new Persistence((Session[0] as AmbienteList)[0]);
                try
                {
                    persist.Delete(new Tarefa(Convert.ToDecimal(codigo)));
                }
                catch (Exception ex)
                {
                    persist.Rollback();
                    throw ex;
                }
                finally
                {
                    persist.Close();
                }
                LoadTarefas();
            }
        }
        private void LoadTarefas()
        {
    
    
            AmbienteList ambList = Session[0] as AmbienteList;
            MainConsult mainConsult = new MainConsult(ambList);
      
            try
            {
                gvTarefasStore.SortInfo.Field = "DATA";
                gvTarefasStore.SortInfo.Direction = Ext.Net.SortDirection.DESC;
                gvTarefasStore.CustomConfig.Add(new ConfigItem("groupDir", "DESC", ParameterMode.Value));
                DataTable dataTable = mainConsult.ExecSQLB(String.Format(QUERY_TAREFAS, ambList[0].UserName), "tarefas").Tables[0];
                gvTarefasStore.DataSource = dataTable;
                gvTarefasStore.DataBind();
    
                gvTarefas.UpdateContent();
    
            }
            finally
            {
                mainConsult.CloseConnection();
            }
        }
        #endregion
    
        #region Informações
        void Click_EventDeleteSelectedInformacoes(object sender, DirectEventArgs e)
        {
    
            Dictionary<String, String>[] selecionados = getSelectedDeleteInformacoes(e);
    
    
            MXM.Persistence.Persistence persist = new Persistence((Session[0] as AmbienteList)[0]);
            try
            {
                foreach (Dictionary<String, String> item in selecionados)
                {
                    persist.Delete(new Rss(Convert.ToDecimal(item["MRSS_CODIGO"])));
                }
            }
            catch (Exception ex)
            {
                persist.Rollback();
                throw ex;
            }
            finally
            {
                persist.Close();
            }
            LoadGridDeleteInformacoes();
        }
        void btnSaveAddInformacoes_Click(object sender, DirectEventArgs e)
        {
            Rss rss = new Rss();
            rss.Titulo = tbAddInfoTitulo.Text;
            rss.Url = tbAddInfoUrl.Text;
            rss.Usuario = (Session[0] as AmbienteList)[0].UserName;
    
            MXM.Persistence.Persistence persist = new Persistence((Session[0] as AmbienteList)[0]);
            try
            {
                persist.StartTransaction();
                Rss auxRss = persist.GetObject(rss) as Rss;
                if (auxRss == null)
                    persist.Save(rss);
                persist.Commit();
                //AddItemInformacoes(CreatePortLet(tbAddInfoTitulo.Text, tbAddInfoUrl.Text));
                tbAddInfoTitulo.Text = String.Empty;
                tbAddInfoUrl.Text = String.Empty;
            }
            catch (Exception ex)
            {
                persist.Rollback();
                throw ex;
            }
            finally
            {
                persist.Close();
            }
            LoadInformacoes();
            WindowAddInformacoes.Close();
            
        }
        private void LoadGridDeleteInformacoes()
        {
            AmbienteList ambList = Session[0] as AmbienteList;
            MainConsult mainConsult = new MainConsult(ambList);
            telaInformacoes.Items.Clear();
            try
            {
                DataTable dataTable = mainConsult.ExecSQLB(String.Format(QUERY_INFORMACOES, ambList[0].UserName), "informações").Tables[0];
                gvDeleteInformacoesStore.DataSource = dataTable;
                gvDeleteInformacoesStore.DataBind();
            }
            finally
            {
                mainConsult.CloseConnection();
            }
        }
        void Click_EventShowDeleteInformacoes(object sender, DirectEventArgs e)
        {
    
            LoadGridDeleteInformacoes();
            windowDeleteInformacoes.Show();
    
        }
        private void LoadInformacoes()
        {
            AmbienteList ambList = Session[0] as AmbienteList;
            MainConsult mainConsult = new MainConsult(ambList);
            if (X.IsAjaxRequest)
            {
                informacoesColumn1.RemoveAll();
                informacoesColumn2.RemoveAll();
                informacoesColumn3.RemoveAll();
            }
            try
            {
                DataTable dataTable = mainConsult.ExecSQLB(String.Format(QUERY_INFORMACOES, ambList[0].UserName), "informações").Tables[0];
                Int32 i = 0;
                for (; i < dataTable.Rows.Count; i += 2)
                {
                    Portlet portlet1 = CreatePortLet(dataTable.Rows[i]["MRSS_TITULO"].ToString(), dataTable.Rows[i]["MRSS_RSS"].ToString());
                    AddItemInformacoes(portlet1);
                    Portlet portlet2 = null;
                    if ((i + 1) < dataTable.Rows.Count)
                    {
    
                        portlet2 = CreatePortLet(dataTable.Rows[i + 1]["MRSS_TITULO"].ToString(), dataTable.Rows[i + 1]["MRSS_RSS"].ToString());
                        AddItemInformacoes(portlet2);      
                    }
                    //telaInformacoes.Items.Add(CreateportalColumn(portlet1, portlet2));
                }
                //telaInformacoes.DoLayout();
            }
            finally
            {
                mainConsult.CloseConnection();
            }
        }
        Int32 col1Items = 0;
        Int32 col2Items = 0;
        private void AddItemInformacoes(Portlet item)//, Boolean remove)
        {
            Boolean included = false;
                    
    
            if (!included)
            {
                if (X.IsAjaxRequest)
                {
    
                    if (col1Items < 2)
                    {
                        item.AddTo(informacoesColumn1);
                        col1Items++;
                    }
                    else if (col2Items < 2)
                    {
                        item.AddTo(informacoesColumn2);
                        col2Items++;
                    }
                    else
                    {
                        item.AddTo(informacoesColumn3);
                    }
                }
                else
                {
                    if (informacoesColumn1.Items.Count < 2)
                    {
                        informacoesColumn1.Items.Add(item);
                    }
                    else if (informacoesColumn2.Items.Count < 2)
                    {
                        informacoesColumn2.Items.Add(item);
                    }
                    else
                    {
                        informacoesColumn3.Items.Add(item);
                    }
                }
            }
        }
    
        private Dictionary<string, string>[] getSelectedDeleteInformacoes(DirectEventArgs e)
        {
            string json = e.ExtraParams["Values"];
            return JSON.Deserialize<Dictionary<string, string>[]>(json);
        }
        #endregion
    
        #region Consultas
        private void LoadConsultas()
        {
            AmbienteList ambList = Session[0] as AmbienteList;
            MainConsult mainConsult = new MainConsult(ambList);
            telaConsultas.Items.Clear();
            try
            {
                DataTable dataTable = mainConsult.ExecSQLB(String.Format(@"
    SELECT  MCN_CODIGO, MCN_TITULO
    FROM    MXS_CONSULTA_MCN,
            MXS_USUARIOCONSULTA_MUC,
            MXS_PERFILUSUARIO_MXPU
    WHERE   MCN_CODIGO = MUC_CONSULTA
    AND     MXPU_PERFILACESSO = MUC_PERFIL
    AND     MXPU_USUARIO = '{0}'
    ", ambList[0].UserName), "consultas").Tables[0];
    
                for (Int32 i = 0; i < dataTable.Rows.Count; i += 2)
                {
                    Portlet portlet1 = CreatePortLet(dataTable.Rows[i]["MCN_TITULO"].ToString(), "Consultas.aspx?CON=" + dataTable.Rows[i]["MCN_CODIGO"].ToString());
                    Portlet portlet2 = null;
                    if ((i + 1) < dataTable.Rows.Count)
                        portlet2 = CreatePortLet(dataTable.Rows[i + 1]["MCN_TITULO"].ToString(), "Consultas.aspx?CON=" + dataTable.Rows[i + 1]["MCN_CODIGO"].ToString());
                    telaConsultas.Items.Add(CreateportalColumn(portlet1, portlet2));
                }
            }
            finally
            {
                mainConsult.CloseConnection();
            }
    
        }
        #endregion
    
        #region Favoritos
        void Click_EventAjudaFavoritos(object sender, Ext.Net.DirectEventArgs e)
        {
            Ext.Net.Notification.Show(new Ext.Net.NotificationConfig()
            {
                Html = "Para adicionar ou remover favoritos utilize o menu ao lado do título na aba da tela",
                Pinned = true,
                Draggable = true,
                Modal = true,
                ShowPin = true,
    
                AlignCfg = new NotificationAlignConfig()
                {
                    ElementAnchor = AnchorPoint.Center,
                    TargetAnchor = AnchorPoint.Center
                }
            });
        }
        #endregion
    
        #region Comum
        private Portlet CreatePortLet(String title, String url)
        {
            Portlet portlet = new Portlet();
            portlet.Title = title;
            portlet.AutoHeight = true;
            portlet.Frame = true;
            portlet.AutoLoad.Url = url;
            portlet.AutoLoad.ShowMask = true;
            portlet.AutoLoad.Mode = LoadMode.IFrame;
            portlet.AutoLoad.MaskMsg = "Carregando " + title + "...";
    
            return portlet;
        }
        
        private PortalColumn CreateportalColumn(Portlet item1, Portlet item2)
        {
            PortalColumn portalColumn = new PortalColumn()
            {
                Layout = "Anchor",
                AutoHeight = true,
                StyleSpec = "padding:5px 0 5px 5px",
                ColumnWidth = 0.33
            };
    
            portalColumn.Items.Add(item1);
            if (item2 != null)
                portalColumn.Items.Add(item2);
            return portalColumn;
        }
        #endregion
    }
    Last edited by Daniil; Aug 16, 2010 at 1:03 PM. Reason: Please use [code] tags
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] [1.0] Dropping portlets into an empty portal...
    By betamax in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: May 26, 2010, 6:38 PM
  2. [CLOSED] [1.0] Portal does not show portlets when scrolling
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 18, 2010, 2:01 PM
  3. Dynamic portal and portlets in code behind
    By Sofficino in forum 1.x Help
    Replies: 1
    Last Post: Jun 08, 2009, 4:42 AM
  4. Replies: 2
    Last Post: Jan 14, 2009, 3:19 PM
  5. [CLOSED] Create Stateful Portal - Save Position and Collapse of Portlets
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 16, 2008, 7:26 PM

Tags for this Thread

Posting Permissions